1 #ifndef STAN_LANG_RETHROW_LOCATED_HPP
2 #define STAN_LANG_RETHROW_LOCATED_HPP
27 (void) dynamic_cast<const E&>(e);
57 const std::string& orig_type)
throw()
58 :
what_(
what +
" [origin: " + orig_type +
"]") {
73 const char*
what()
const throw() {
90 using std::bad_exception;
91 using std::bad_typeid;
94 using std::domain_error;
95 using std::invalid_argument;
96 using std::length_error;
97 using std::out_of_range;
98 using std::logic_error;
100 using std::overflow_error;
101 using std::range_error;
102 using std::underflow_error;
103 using std::runtime_error;
105 using std::exception;
108 o <<
"Exception thrown at line " << line <<
": "
110 std::string s = o.str();
112 if (is_type<bad_alloc>(e))
114 if (is_type<bad_cast>(e))
116 if (is_type<bad_exception>(e))
118 if (is_type<bad_typeid>(e))
120 if (is_type<std::ios_base::failure>(e))
121 throw std::ios_base::failure(s);
122 if (is_type<domain_error>(e))
123 throw domain_error(s);
124 if (is_type<invalid_argument>(e))
125 throw invalid_argument(s);
126 if (is_type<length_error>(e))
127 throw length_error(s);
128 if (is_type<out_of_range>(e))
129 throw out_of_range(s);
130 if (is_type<logic_error>(e))
131 throw logic_error(s);
132 if (is_type<overflow_error>(e))
133 throw overflow_error(s);
134 if (is_type<range_error>(e))
135 throw range_error(s);
136 if (is_type<underflow_error>(e))
137 throw underflow_error(s);
138 if (is_type<runtime_error>(e))
139 throw runtime_error(s);
Structure for a located exception for standard library exception types that have no what-based constr...
Probability, optimization and sampling library.
located_exception()
Construct a located exception with no what message.
~located_exception()
Destroy a located exception.
bool is_type(const std::exception &e)
Returns true if the specified exception can be dynamically cast to the template parameter type...
const char * what() const
Return the character sequence describing the exception, including the original waht message and origi...
void rethrow_located(const std::exception &e, int line)
Rethrow an exception of type specified by the dynamic type of the specified exception, adding the specified line number to the specified exception's message.
located_exception(const std::string &what, const std::string &orig_type)
Construct a located exception with the specified what message and specified original type...