Skip to content

Commit

Permalink
feat: catch formulation errors and report feature and timestep (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
hellkite500 committed Mar 27, 2024
1 parent 9758d43 commit 16662c1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion include/core/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "LayerData.hpp"
#include "Simulation_Time.hpp"
#include "State_Exception.hpp"

#ifdef NGEN_MPI_ACTIVE
#include "HY_Features_MPI.hpp"
Expand Down Expand Up @@ -92,7 +93,17 @@ namespace ngen
auto r = features.catchment_at(id);
//TODO redesign to avoid this cast
auto r_c = std::dynamic_pointer_cast<realization::Catchment_Formulation>(r);
double response = r_c->get_response(output_time_index, simulation_time.get_output_interval_seconds());
double response(0.0);
try{
response = r_c->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 feature id "+id;
throw models::external::State_Exception(msg);
}
std::string output = std::to_string(output_time_index)+","+current_timestamp+","+
r_c->get_output_line_for_timestep(output_time_index)+"\n";
r_c->write_output(output);
Expand Down

0 comments on commit 16662c1

Please sign in to comment.