00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SBUILD_CUSTOM_ERROR_H
00021 #define SBUILD_CUSTOM_ERROR_H
00022
00023 #include <sbuild/sbuild-error.h>
00024
00025 #include <map>
00026 #include <string>
00027
00028 namespace sbuild
00029 {
00030
00034 template <typename T>
00035 class custom_error : public runtime_error
00036 {
00037 public:
00038 typedef T error_type;
00039 typedef std::map<error_type,const char *> map_type;
00040
00046 custom_error (error_type error):
00047 runtime_error(format_error(std::string(), error))
00048 {
00049 }
00050
00057 custom_error (std::string const& detail,
00058 error_type error):
00059 runtime_error(format_error(detail, error))
00060 {
00061 }
00062
00068 custom_error (std::string const& detail):
00069 runtime_error(detail)
00070 {
00071 }
00072
00079 custom_error (error_type error,
00080 int error_number):
00081 runtime_error(format_error(std::string(), error, error_number))
00082 {
00083 }
00084
00092 custom_error (std::string const& detail,
00093 error_type error,
00094 int error_number):
00095 runtime_error(format_error(detail, error, error_number))
00096 {
00097 }
00098
00105 custom_error (std::string const& detail,
00106 int error_number):
00107 runtime_error(format_error(detail, error_number))
00108 {
00109 }
00110
00117 custom_error (error_type error,
00118 std::string const& error_string):
00119 runtime_error(format_error(std::string(), error, error_string))
00120 {
00121 }
00122
00130 custom_error (std::string const& detail,
00131 error_type error,
00132 std::string const& error_string):
00133 runtime_error(format_error(detail, error, error_string))
00134 {
00135 }
00136
00143 custom_error (std::string const& detail,
00144 std::string const& error_string):
00145 runtime_error(format_error(detail, error_string))
00146 {
00147 }
00148
00150 virtual ~custom_error () throw ()
00151 {}
00152
00153 private:
00155 static map_type error_strings;
00156
00163 static const char *
00164 get_error (error_type error);
00165
00173 static std::string
00174 format_error (std::string const& detail,
00175 error_type error);
00176
00185 static std::string
00186 format_error (std::string const& detail,
00187 error_type error,
00188 int error_number);
00189
00197 static std::string
00198 format_error (std::string const& detail,
00199 int error_number);
00200
00209 static std::string
00210 format_error (std::string const& detail,
00211 error_type error,
00212 std::string const& error_string);
00213
00221 static std::string
00222 format_error (std::string const& detail,
00223 std::string const& error_string);
00224 };
00225
00226
00227 }
00228
00229 #include "sbuild-custom-error.tcc"
00230
00231 #endif
00232
00233
00234
00235
00236
00237