Skip to content

Commit

Permalink
feat: add layer and time context to possible formulation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hellkite500 committed Apr 8, 2024
1 parent 582eea2 commit 11ddad4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion include/core/DomainLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Catchment_Formulation.hpp"
#include "Layer.hpp"
#include "State_Exception.hpp"

namespace ngen
{
Expand Down Expand Up @@ -56,8 +57,18 @@ namespace ngen
* is not yet implemented in this class.
*/
void update_models() override{
formulation->get_response(output_time_index, simulation_time.get_output_interval_seconds());
std::string current_timestamp = simulation_time.get_timestamp(output_time_index);
try{
formulation->get_response(output_time_index, simulation_time.get_output_interval_seconds());
}
catch(models::external::State_Exception& e){
std::string msg = e.what();
msg = msg+" at timestep "+std::to_string(output_time_index)
+" ("+current_timestamp+")"
+" at domain layer "+description.name
+" (layer id: "+std::to_string(description.id)+")";
throw models::external::State_Exception(msg);
}
std::string output = std::to_string(output_time_index)+","+current_timestamp+","+
formulation->get_output_line_for_timestep(output_time_index)+"\n";
formulation->write_output(output);
Expand Down

0 comments on commit 11ddad4

Please sign in to comment.