2 #ifndef WIBBLE_EXCEPTION_H
3 #define WIBBLE_EXCEPTION_H
109 static std::vector< std::string > &
context() {
112 s_context =
new std::vector< std::string >();
116 template<
typename O >
157 return "no context information available";
159 std::stringstream res;
161 std::ostream_iterator< std::string >( res,
", \n " ) );
162 std::string r = res.str();
163 return std::string( r, 0, r.length() - 7 );
166 const std::vector<std::string>&
context()
const throw ()
190 virtual const char*
type()
const throw () {
return "Generic"; }
193 virtual std::string
desc()
const throw ()
195 return "an unspecified problem happened; if you see this message, please report a bug to the maintainer";
205 virtual const std::string&
fullInfo()
const throw ()
213 virtual const char*
what()
const throw () {
return fullInfo().c_str(); }
230 virtual const char*
type()
const throw () {
return "Interrupted"; }
247 virtual const char*
type()
const throw () {
return "WaitInterrupted"; }
260 Generic(context), m_error(error) {}
263 virtual const char*
type()
const throw () {
return "Consistency"; }
265 virtual std::string
desc()
const throw ()
268 return "consistency check failed";
279 virtual std::string
typeinfo()
const throw() {
return "unknown types"; }
280 virtual std::string
desc()
const throw() {
281 return std::string(
"bad cast: " ) +
typeinfo();
286 template<
typename From,
typename To >
289 BadCastExt(
const std::string &error = std::string() ) throw()
293 virtual std::string
typeinfo()
const throw() {
return std::string(
"from " )
294 +
typeid( From ).name()
296 +
typeid( To ).name(); }
319 virtual const char*
type()
const throw () {
return "OutOfRange"; }
324 virtual std::string
desc()
const throw () {
return m_var_desc +
" out of range"; }
356 const std::string&
context)
throw ()
362 virtual C
val()
const throw () {
return m_val; }
370 virtual const char*
type()
const throw ()
372 return "ValOutOfRange<>";
375 virtual std::string
desc()
const throw ();
405 virtual const char*
type()
const throw () {
return "System"; }
408 virtual int code()
const throw () {
return m_errno; }
411 virtual std::string
desc()
const throw ();
426 File(
const std::string& name,
const std::string&
context)
throw () :
427 System(
context), m_name(name) {}
430 virtual const char*
type()
const throw () {
return "File"; }