8 #ifndef SCARAB_BASE_EXCEPTION_HH_ 9 #define SCARAB_BASE_EXCEPTION_HH_ 33 virtual const char* where()
const noexcept = 0;
54 template<
typename x_derived >
65 template<
class x_streamable >
66 x_derived&
operator<<( x_streamable a_fragment );
67 x_derived&
operator<<(
const std::string& a_fragment );
68 x_derived&
operator<<(
const char* a_fragment );
70 x_derived& operator()(
const std::string& a_filename,
int a_line );
72 virtual const char* what()
const noexcept;
73 virtual const char* where()
const noexcept;
75 const std::string& filename()
const;
86 template<
typename x_derived >
95 template<
typename x_derived >
105 f_filename = a_filename;
113 template<
typename x_derived >
116 f_what( a_orig.f_what ),
119 f_line( a_orig.f_line )
123 f_filename = a_orig.f_filename;
131 template<
typename x_derived >
135 template<
typename x_derived >
138 f_what = a_orig.f_error;
142 template<
typename x_derived >
145 return f_what.c_str();
148 template<
typename x_derived >
159 return f_where.c_str();
162 template<
typename x_derived >
163 template<
class x_streamable >
166 std::stringstream stream;
167 stream << a_fragment;
168 f_what += stream.str();
169 return *
static_cast< x_derived*
>(
this);
172 template<
typename x_derived >
175 f_what += a_fragment;
176 return *
static_cast< x_derived*
>(
this);
179 template<
typename x_derived >
182 f_what += std::string( a_fragment );
183 return *
static_cast< x_derived*
>(
this);
186 template<
typename x_derived >
189 f_filename = a_filename;
191 return *
static_cast< x_derived*
>(
this);
194 template<
typename x_derived >
200 template<
typename x_derived >
Base class for exceptions with streaming operators and filename/line number location.
virtual const char * what() const noexcept
typed_exception() noexcept
x_derived & operator()(const std::string &a_filename, int a_line)
x_derived & operator<<(x_streamable a_fragment)
const std::string & filename() const
virtual ~typed_exception() noexcept
SCARAB_API std::ostream & operator<<(std::ostream &out, const param_array &a_value)
typed_exception< x_derived > & operator=(const typed_exception< x_derived > &a_orig)
virtual const char * where() const noexcept
Base class for exceptions with what() and where() functions.
auto to_string(T &&value) -> decltype(std::forward< T >(value))
Convert an object to a string (directly forward if this can become a string)