ncsu-landscape-dynamics / rpops

PoPS (Pest or Pathogen Spread) R Package
https://ncsu-landscape-dynamics.github.io/rpops/
GNU General Public License v3.0
10 stars 5 forks source link

stop execution instead of return text for failed check #107

Closed nkruskamp closed 2 years ago

nkruskamp commented 3 years ago

During preliminary checks (particularly in my case those related to files not existing), stop execution and throw an error instead of returning a string.

nkruskamp commented 3 years ago

I think would probably be a bigger change than just adding a few lines based on the way the code is written between checks and configuration, but an example would be to replace this section:

https://github.com/ncsu-landscape-dynamics/rpops/blob/d4d754c7ad335b9e57e6114bedbf734e8868b4ba/R/checks.R#L14

with something like this:

ras_files_exist <- sapply(raster_file_list, function(x) {
  exists <- file.exists(x)
  if (!exists) {
    print(paste(x, exists))
  }
  return(exists)
})
stopifnot(ras_files_exist, "file doesn't exist")