try_blocks.h
Go to the documentation of this file.
1 #ifndef fhiclcpp_detail_try_blocks_h
2 #define fhiclcpp_detail_try_blocks_h
3 
4 #include "fhiclcpp/exception.h"
5 
6 #include <string>
7 
8 namespace fhicl::detail {
9  template <typename L>
10  void
11  try_insert(L l, std::string const& key) try {
12  l(key);
13  }
14  catch (boost::bad_lexical_cast const& e) {
15  throw fhicl::exception{cant_insert, key} << e.what();
16  }
17  catch (boost::bad_numeric_cast const& e) {
18  throw fhicl::exception{cant_insert, key} << e.what();
19  }
20  catch (fhicl::exception const& e) {
21  throw fhicl::exception{cant_insert, key, e};
22  }
23  catch (std::exception const& e) {
24  throw fhicl::exception{cant_insert, key} << e.what();
25  }
26 }
27 
28 #endif /* fhiclcpp_detail_try_blocks_h */
29 
30 // Local variables:
31 // mode: c++
32 // End:
std::string string
Definition: nybbler.cc:12
static QStrList * l
Definition: config.cpp:1044
void try_insert(L l, std::string const &key)
Definition: try_blocks.h:11
const double e
def key(type, name=None)
Definition: graph.py:13
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33