X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_exception.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_exception.h;h=aa12e28f95286acbe38ef06bdc89ee91839c5b36;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/scd/scd_exception.h b/dol/src/dol/visitor/hdsd/scd/scd_exception.h new file mode 100644 index 0000000..aa12e28 --- /dev/null +++ b/dol/src/dol/visitor/hdsd/scd/scd_exception.h @@ -0,0 +1,57 @@ +#ifndef SCD_EXCEPTION_H +#define SCD_EXCEPTION_H + +#include +#include +#include + + +/** + * Maximum level of stacktrace. + */ +const int SCD_EX_TRACES = 15; + + +/** + * General exeption. Can give a stack trace and generates error messages + * from error numbers. + */ +class scd_exception : public std::exception +{ +public: + /** + * Constructor to create an exception with a string as cause. + * \param the cause + */ + scd_exception(const std::string& msg); + + /** + * Constroctor to create an exception with a string and an error + * message generated from an error number (errno) as cause. + * \param the cause prefix + * \param the error number to generate the error message for + */ + scd_exception(const std::string& msg, int errn); + + virtual ~scd_exception() throw() {} + + /** + * Returns a C-String showing the cause of the exception. + */ + virtual const char* what() throw(); + + /** + * Returns a C-String showing the stack trace. For name resolution + * -rdynamic has to be used while compiling. + */ + const char* stacktrace(); + +private: + std::string _msg; + std::string _backtrace; + + void _get_backtrace(); + +}; + +#endif