From 86cbc543aa93c8e423ef5e3099be58d59df47399 Mon Sep 17 00:00:00 2001 From: hellkite500 Date: Thu, 2 Nov 2023 07:12:43 -0600 Subject: [PATCH] better error reporting when bmi init file's are not readable --- include/realizations/catchment/Bmi_Adapter.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/realizations/catchment/Bmi_Adapter.hpp b/include/realizations/catchment/Bmi_Adapter.hpp index 640ef34d5f..5f04124ba6 100644 --- a/include/realizations/catchment/Bmi_Adapter.hpp +++ b/include/realizations/catchment/Bmi_Adapter.hpp @@ -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); } } @@ -169,12 +170,13 @@ namespace models { "Previous " + model_name + " init attempt had exception: \n\t" + init_exception_msg); } // If there was previous init attempt w/ (implicitly) no exception on previous attempt, just return + errno = 0; else if (model_initialized) { return; } 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 {