libMesh / libmesh

libMesh github repository
http://libmesh.github.io
GNU Lesser General Public License v2.1
654 stars 287 forks source link

Better Error Message for getting non-existent Parameters #275

Closed friedmud closed 9 years ago

friedmud commented 10 years ago

If you call parameters.get<Real>("something") when "something" doesn't exist you get an error message like:

Stack frames: 15
0: 0   libmesh_oprof.0.dylib               0x000000010b941ca9 libMesh::print_trace(std::ostream&) + 57
1: 1   libmesh_oprof.0.dylib               0x000000010b9402f0 libMesh::MacroFunctions::report_error(char const*, int, char const*, char const*) + 48
2: 2   librelap-7-oprof.0.dylib            0x000000010a2d1734 double const& libMesh::Parameters::get<double>(std::string const&) const + 372
3: 3   librelap-7-oprof.0.dylib            0x000000010a5365da Pipe::Pipe(std::string const&, InputParameters) + 1914
4: 4   librelap-7-oprof.0.dylib            0x000000010a3ba984 MooseObject* buildObject<Pipe>(std::string const&, InputParameters) + 68
5: 5   libmoose-oprof.0.dylib              0x000000010ae358ad Factory::create(std::string const&, std::string const&, InputParameters) + 173
6: 6   librelap-7-oprof.0.dylib            0x000000010a3afa67 Simulation::addComponent(std::string const&, std::string const&, InputParameters) + 151
7: 7   librelap-7-oprof.0.dylib            0x000000010a2bde82 AddComponentAction::act() + 242
8: 8   libmoose-oprof.0.dylib              0x000000010ad51110 ActionWarehouse::executeActionsWithAction(std::string const&) + 272
9: 9   libmoose-oprof.0.dylib              0x000000010ad50fa1 ActionWarehouse::executeAllActions() + 225
10: 10  librelap-7-oprof.0.dylib            0x000000010a375276 Relap7App::runInputFile() + 246
11: 11  libmoose-oprof.0.dylib              0x000000010ae95af8 MooseApp::run() + 24
12: 12  relap-7-oprof                       0x000000010a073e9a main + 106
13: 13  relap-7-oprof                       0x000000010a073e24 start + 52
14: 14  ???                                 0x0000000000000003 0x0 + 3
[0] /Users/gastdr/projects/libmesh/include/libmesh/parameters.h, line 448, compiled Jun 17 2014 at 17:16:46
ERROR: no double parameter named "Tw_transferred":
Name     Type    Value
---------------------
 A   double  0.44934
 A_func  std::string     
 Dh  double  0.002972
 HT_geometry_code    unsigned int    0
 Hw  double  0
 P_func  std::string     
 P_liquid_func   std::string     
 P_vapor_func    std::string     
 Phf     double  0
 PoD     double  1
 T_func  std::string     
 T_liquid_func   std::string     
 T_vapor_func    std::string     
 Tw  double  0
 Tw_transferred  bool    0
 V_func  std::string     
 V_liquid_func   std::string     
 V_vapor_func    std::string     
 _moose_app  MooseApp*   0x7fdb71809600
 _moose_base     std::string     Component
 _sim    Simulation*     0x7fdb7180a000
 built_by_action     std::string     add_component
 component_type  std::string     pipe
 controlled  MooseEnum   
 eos     UserObjectName  eos
 eos_liquid  UserObjectName  
 eos_vapor   UserObjectName  
 f   double  0.001
 f_interface     double  0
 initial_P   double  0
 initial_T   double  0
 initial_V   double  0
 initial_volume_fraction_vapor   double  0
 length  double  1
 long_name   std::string     Components/pipe1
 model_type  int     -1223862639
 monitored   MooseEnum   
 n_elems     unsigned int    5
 offset  std::vector<double, std::allocator<double> >    0 0 0 
 operators   MooseEnum   
 orientation     std::vector<double, std::allocator<double> >    0 -1 0 
 physics_input_file  std::string     
 position    std::vector<double, std::allocator<double> >    0 1 0 
 q_wall  double  0
 q_wall_func     std::string     
 rotation    double  0
 roughness   double  0
 shape_factor    double  1
 shock_capturing     bool    134
 stabilization_type  MooseEnum   
 volume_fraction_vapor_func  std::string

The actual error message is a bit buried. It would be better if the error came out first and then a bit of space then the list of things in the Parameters object then the stack trace...

I'm mostly putting this here as a reminder to myself and to have a bit of discussion. This isn't a call for anyone to do anything (unless someone is bored!)

jwpeterson commented 9 years ago

Fixed in #591.