00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PALUDIS_GUARD_PALUDIS_EXCEPTION_HH
00021 #define PALUDIS_GUARD_PALUDIS_EXCEPTION_HH 1
00022
00023 #include <paludis/util/attributes.hh>
00024 #include <string>
00025 #include <exception>
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 namespace paludis
00039 {
00040
00041
00042
00043
00044
00045
00046 class PALUDIS_VISIBLE Context
00047 {
00048 private:
00049 Context(const Context &);
00050 const Context & operator= (const Context &);
00051
00052 public:
00053
00054
00055
00056 Context(const std::string &);
00057
00058 ~Context();
00059
00060
00061
00062
00063
00064
00065 static std::string backtrace(const std::string & delim);
00066 };
00067
00068
00069
00070
00071
00072
00073
00074 class PALUDIS_VISIBLE Exception :
00075 public std::exception
00076 {
00077 private:
00078 const std::string _message;
00079 mutable std::string _what_str;
00080 struct ContextData;
00081 ContextData * const _context_data;
00082
00083 const Exception & operator= (const Exception &);
00084
00085 protected:
00086
00087
00088
00089 Exception(const std::string & message) throw ();
00090
00091 Exception(const Exception &);
00092
00093
00094
00095 public:
00096
00097
00098
00099 virtual ~Exception() throw () PALUDIS_ATTRIBUTE((nothrow));
00100
00101
00102
00103
00104
00105
00106 const std::string & message() const throw () PALUDIS_ATTRIBUTE((nothrow));
00107
00108
00109
00110
00111 std::string backtrace(const std::string & delim) const;
00112
00113
00114
00115
00116 bool empty() const;
00117
00118
00119
00120
00121 const char * what() const throw ();
00122 };
00123
00124
00125
00126
00127
00128
00129
00130
00131 class PALUDIS_VISIBLE InternalError :
00132 public Exception
00133 {
00134 public:
00135
00136
00137
00138
00139
00140
00141
00142 InternalError(const std::string & location, const std::string & message) throw ();
00143 };
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 class PALUDIS_VISIBLE NotAvailableError :
00154 public Exception
00155 {
00156 public:
00157
00158
00159
00160 NotAvailableError(const std::string & message) throw ();
00161 };
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 class PALUDIS_VISIBLE NameError :
00172 public Exception
00173 {
00174 protected:
00175
00176
00177
00178
00179
00180
00181 NameError(const std::string & name, const std::string & role) throw ();
00182
00183
00184
00185
00186
00187
00188
00189
00190 NameError(const std::string & name, const std::string & role,
00191 const std::string & msg) throw ();
00192 };
00193
00194
00195
00196
00197
00198
00199
00200 class PALUDIS_VISIBLE ConfigurationError :
00201 public Exception
00202 {
00203 public:
00204
00205
00206
00207 ConfigurationError(const std::string & msg) throw ();
00208 };
00209
00210
00211
00212
00213
00214
00215
00216 #define PALUDIS_HERE (std::string(__PRETTY_FUNCTION__) + " at " + \
00217 std::string(__FILE__) + ":" + paludis::stringify(__LINE__))
00218 }
00219
00220 #endif