[cig-commits] [commit] master: add try/catch around functionparser to give more info (0de9eff)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed May 21 04:38:43 PDT 2014
Repository : https://github.com/geodynamics/aspect
On branch : master
Link : https://github.com/geodynamics/aspect/compare/1baa8f4d732ef72f666a3a03d0a9052a0dcd7564...e5fba042ca216f9aad0ec38444c4993d0139a6cb
>---------------------------------------------------------------
commit 0de9effb609fdb1f05547a95834c4f2d06a185a3
Author: Timo Heister <timo.heister at gmail.com>
Date: Wed May 21 00:34:05 2014 -0400
add try/catch around functionparser to give more info
It is frustrating if you have a parser error inside FunctionParser
because it won't tell you which expression is wrong or which parameter
in the prm is wrong. This is now fixed.
>---------------------------------------------------------------
0de9effb609fdb1f05547a95834c4f2d06a185a3
source/compositional_initial_conditions/function.cc | 10 ++++++++++
source/heating_model/function.cc | 13 ++++++++++++-
source/initial_conditions/adiabatic.cc | 10 ++++++++++
source/initial_conditions/function.cc | 9 +++++++++
source/mesh_refinement/minimum_refinement_function.cc | 10 ++++++++++
source/velocity_boundary_conditions/function.cc | 9 +++++++++
6 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/source/compositional_initial_conditions/function.cc b/source/compositional_initial_conditions/function.cc
index b7ae323..b0fb43c 100644
--- a/source/compositional_initial_conditions/function.cc
+++ b/source/compositional_initial_conditions/function.cc
@@ -70,10 +70,20 @@ namespace aspect
prm.enter_subsection("Compositional initial conditions");
{
prm.enter_subsection("Function");
+ try
{
function.reset (new Functions::ParsedFunction<dim>(n_compositional_fields));
function->parse_parameters (prm);
}
+ catch (...)
+ {
+ std::cerr << "ERROR: FunctionParser failed to parse\n"
+ << "\t'Compositional initial conditions.Function'\n"
+ << "with expression\n"
+ << "\t'" << prm.get("Function expression") << "'";
+ throw;
+ }
+
prm.leave_subsection();
}
prm.leave_subsection();
diff --git a/source/heating_model/function.cc b/source/heating_model/function.cc
index 3e926dc..28184b0 100644
--- a/source/heating_model/function.cc
+++ b/source/heating_model/function.cc
@@ -83,9 +83,20 @@ namespace aspect
prm.enter_subsection("Heating model");
{
prm.enter_subsection("Function");
+ try
{
- heating_model_function.parse_parameters (prm);
+ heating_model_function.parse_parameters (prm);
}
+ catch (...)
+ {
+ std::cerr << "ERROR: FunctionParser failed to parse\n"
+ << "\t'Heating model.Function'\n"
+ << "with expression\n"
+ << "\t'" << prm.get("Function expression") << "'";
+ throw;
+ }
+ {
+ }
prm.leave_subsection();
}
prm.leave_subsection();
diff --git a/source/initial_conditions/adiabatic.cc b/source/initial_conditions/adiabatic.cc
index 7efca8c..2a8e135 100644
--- a/source/initial_conditions/adiabatic.cc
+++ b/source/initial_conditions/adiabatic.cc
@@ -247,10 +247,20 @@ namespace aspect
if (n_compositional_fields > 0)
{
prm.enter_subsection("Function");
+ try
{
function.reset (new Functions::ParsedFunction<1>(n_compositional_fields));
function->parse_parameters (prm);
}
+ catch (...)
+ {
+ std::cerr << "ERROR: FunctionParser failed to parse\n"
+ << "\t'Initial conditions.Adiabatic.Function'\n"
+ << "with expression\n"
+ << "\t'" << prm.get("Function expression") << "'";
+ throw;
+ }
+
prm.leave_subsection();
}
}
diff --git a/source/initial_conditions/function.cc b/source/initial_conditions/function.cc
index 9e62cf5..0a9f97e 100644
--- a/source/initial_conditions/function.cc
+++ b/source/initial_conditions/function.cc
@@ -62,9 +62,18 @@ namespace aspect
prm.enter_subsection("Initial conditions");
{
prm.enter_subsection("Function");
+ try
{
function.parse_parameters (prm);
}
+ catch (...)
+ {
+ std::cerr << "ERROR: FunctionParser failed to parse\n"
+ << "\t'Initial conditions.Function'\n"
+ << "with expression\n"
+ << "\t'" << prm.get("Function expression") << "'";
+ throw;
+ }
prm.leave_subsection();
}
prm.leave_subsection();
diff --git a/source/mesh_refinement/minimum_refinement_function.cc b/source/mesh_refinement/minimum_refinement_function.cc
index d6e0eff..0f4b64f 100644
--- a/source/mesh_refinement/minimum_refinement_function.cc
+++ b/source/mesh_refinement/minimum_refinement_function.cc
@@ -92,9 +92,19 @@ namespace aspect
prm.enter_subsection("Mesh refinement");
{
prm.enter_subsection("Minimum refinement function");
+ try
{
min_refinement_level.parse_parameters (prm);
}
+ catch (...)
+ {
+ std::cerr << "ERROR: FunctionParser failed to parse\n"
+ << "\t'Mesh refinement.Minimum refinement function'\n"
+ << "with expression\n"
+ << "\t'" << prm.get("Function expression") << "'";
+ throw;
+ }
+
prm.leave_subsection();
}
prm.leave_subsection();
diff --git a/source/velocity_boundary_conditions/function.cc b/source/velocity_boundary_conditions/function.cc
index 7060335..56ed881 100644
--- a/source/velocity_boundary_conditions/function.cc
+++ b/source/velocity_boundary_conditions/function.cc
@@ -94,9 +94,18 @@ namespace aspect
prm.enter_subsection("Boundary velocity model");
{
prm.enter_subsection("Function");
+ try
{
boundary_velocity_function.parse_parameters (prm);
}
+ catch (...)
+ {
+ std::cerr << "ERROR: FunctionParser failed to parse\n"
+ << "\t'Boundary velocity model.Function'\n"
+ << "with expression\n"
+ << "\t'" << prm.get("Function expression") << "'";
+ throw;
+ }
prm.leave_subsection();
}
prm.leave_subsection();
More information about the CIG-COMMITS
mailing list