00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00023
00024 #include <errno.h>
00025 #include <cstring>
00026
00027 #define prefix_ inline
00028
00029
00030
00031
00032
00033 prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description)
00034 : what_(description)
00035 {
00036 #ifdef SENF_BACKTRACE
00037 addBacktrace();
00038 #endif
00039 }
00040
00041 prefix_ std::string senf::ExceptionMixin::message()
00042 const
00043 {
00044 #ifdef SENF_DEBUG
00045 return what_.substr(excLen_);
00046 #else
00047 return what_;
00048 #endif
00049 }
00050
00051 prefix_ std::string senf::ExceptionMixin::backtrace()
00052 const
00053 {
00054 #ifdef SENF_DEBUG
00055 return what_.substr(0,excLen_-4);
00056 #else
00057 return "";
00058 #endif
00059 }
00060
00061 prefix_ void senf::ExceptionMixin::append(std::string text)
00062 {
00063 what_ += text;
00064 }
00065
00066
00067
00068
00069 prefix_ senf::Exception::Exception(std::string const & description)
00070 : ExceptionMixin(description)
00071 {}
00072
00073
00074
00075
00076 prefix_ senf::SystemException::SystemException(std::string const & descr _SENF_EXC_DEBUG_ARGS_ND)
00077 {
00078 init(descr, errno _SENF_EXC_DEBUG_ARGS_P);
00079 }
00080
00081 prefix_ senf::SystemException::SystemException(int code _SENF_EXC_DEBUG_ARGS_ND)
00082 {
00083 init("", code _SENF_EXC_DEBUG_ARGS_P);
00084 }
00085
00086 prefix_ senf::SystemException::SystemException(std::string const & descr, int code
00087 _SENF_EXC_DEBUG_ARGS_ND)
00088 {
00089 init(descr, code _SENF_EXC_DEBUG_ARGS_P);
00090 }
00091
00092 prefix_ int senf::SystemException::errorNumber()
00093 const
00094 {
00095 return code_;
00096 }
00097
00098 prefix_ char const * senf::SystemException::errorString()
00099 const
00100 {
00101 return std::strerror(code_);
00102 }
00103
00104 prefix_ bool senf::SystemException::anyOf(int c0, int c1, int c2, int c3, int c4, int c5,
00105 int c6, int c7, int c8, int c9)
00106 const
00107 {
00108 return
00109 (c0 && code_ == c0) ||
00110 (c1 && code_ == c1) ||
00111 (c2 && code_ == c2) ||
00112 (c3 && code_ == c3) ||
00113 (c4 && code_ == c4) ||
00114 (c5 && code_ == c5) ||
00115 (c6 && code_ == c6) ||
00116 (c7 && code_ == c7) ||
00117 (c8 && code_ == c8) ||
00118 (c9 && code_ == c9);
00119 }
00120
00121 prefix_ senf::SystemException::~SystemException()
00122 throw()
00123 {}
00124
00125
00126 #undef prefix_
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137