00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SBUILD_ERROR_H
00021 #define SBUILD_ERROR_H
00022
00023 #include <map>
00024 #include <stdexcept>
00025 #include <string>
00026
00027 namespace sbuild
00028 {
00029
00033 template <typename T>
00034 class error : public std::runtime_error
00035 {
00036 public:
00037 typedef T error_type;
00038 typedef std::map<error_type,const char *> map_type;
00039
00045 error(std::string const& error):
00046 runtime_error(error)
00047 {
00048 }
00049
00051 virtual ~error () throw ()
00052 {}
00053
00054 private:
00056 static map_type error_strings;
00057
00064 static const char *
00065 get_error (error_type error);
00066
00067 protected:
00079 template <typename A, typename B, typename C, typename D, typename E>
00080 static std::string
00081 format_error (A const& context1,
00082 B const& context2,
00083 C const& context3,
00084 error_type error,
00085 D const& detail1,
00086 E const& detail2);
00087
00099 template <typename A, typename B, typename C, typename D, typename E>
00100 static std::string
00101 format_error (A const& context1,
00102 B const& context2,
00103 C const& context3,
00104 std::runtime_error const& error,
00105 D const& detail1,
00106 E const& detail2);
00107
00108 };
00109
00110 }
00111
00112 #include "sbuild-error.tcc"
00113
00114 #endif
00115
00116
00117
00118
00119
00120