Skip to content

Commit

Permalink
better error reporting when bmi init file's are not readable
Browse files Browse the repository at this point in the history
  • Loading branch information
hellkite500 committed Nov 2, 2023
1 parent 3d07831 commit c197feb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/realizations/catchment/Bmi_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ namespace models {
{
// This replicates a lot of Initialize, but it's necessary to be able to do it separately to support
// "initializing" on construction, given using Initialize requires use of virtual functions
errno = 0;
if (!utils::FileChecker::file_is_readable(this->bmi_init_config)) {
init_exception_msg = "Cannot create and initialize " + this->model_name + " using unreadable file '"
+ this->bmi_init_config + "'";
+ this->bmi_init_config + "'. Error: "+std::strerror(errno);
throw std::runtime_error(init_exception_msg);
}
}
Expand Down Expand Up @@ -164,6 +165,7 @@ namespace models {
void Initialize() {
// If there was previous init attempt but w/ failure exception, throw runtime error and include previous
// message
errno = 0;
if (model_initialized && !init_exception_msg.empty()) {
throw std::runtime_error(
"Previous " + model_name + " init attempt had exception: \n\t" + init_exception_msg);
Expand All @@ -174,7 +176,7 @@ namespace models {
}
else if (!utils::FileChecker::file_is_readable(bmi_init_config)) {
init_exception_msg = "Cannot initialize " + model_name + " using unreadable file '"
+ bmi_init_config + "'";
+ bmi_init_config + "'. Error: "+std::strerror(errno);;
throw std::runtime_error(init_exception_msg);
}
else {
Expand Down

0 comments on commit c197feb

Please sign in to comment.