Skip to content

Commit

Permalink
Merge pull request #273 from USEPA/issue_269
Browse files Browse the repository at this point in the history
improve error handling for missing model spec
  • Loading branch information
bl-young authored Jan 15, 2024
2 parents 1c154d8 + 913041d commit bffcfef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions R/ConfigurationFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ getConfiguration <- function(configname, configtype, configpaths = NULL, pkg="us
}
}
config <- configr::read.config(configpath)
if (typeof(config) == "logical" && config == FALSE) {
logging::logwarn(paste0("Configuration not found for ", configname))
return(NULL)
}
return(config)
}

Expand Down
2 changes: 1 addition & 1 deletion R/InitializeModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ initializeModel <- function(modelname, configpaths = NULL) {
model <- list()
# Get model specs
model$specs <- getConfiguration(modelname, "model", configpaths)
if (rlang::is_na(model$specs)) {
if (is.null(model$specs)) {
stop(paste("No configuration exists for a model named", modelname))
} else {
# Get model crosswalk
Expand Down

0 comments on commit bffcfef

Please sign in to comment.