00001
00002
00003
00004 #ifndef __Phaser_Io__Error__Classes__
00005 #define __Phaser_Io__Error__Classes__
00006
00007 #include <string>
00008 #include <vector>
00009 #include <exception>
00010
00011 namespace phaser_io {
00012
00013
00014 #define PROGRAM_INTERNAL_ERROR() ::phaser_io::error(__FILE__, __LINE__)
00015 #define PROGRAM_NOT_IMPLEMENTED() ::phaser_io::error(__FILE__, __LINE__, \
00016 "Not implemented.")
00017 #define PROGRAM_ASSERT(bool) \
00018 if (!(bool)) throw ::phaser_io::error(__FILE__, __LINE__,\
00019 "Consistency check (" # bool ") failure.")
00020
00021 class error : public std::exception
00022 {
00023 public:
00024 explicit
00025 error(std::string const& msg) throw();
00026
00027 error(const char* file, long line, std::string const& msg = "",
00028 bool internal = true) throw();
00029
00030 virtual ~error() throw();
00031
00032 virtual const char* what() const throw();
00033
00034 protected:
00035 std::string msg_;
00036 };
00037
00038 class InputError : public std::exception
00039 {
00040 private:
00041 std::string message;
00042 std::string echo;
00043 public:
00044 virtual const char* what() const throw() { return message.c_str(); }
00045 virtual ~InputError() throw() {}
00046 InputError(std::string e,std::string m);
00047 std::string Message();
00048 std::string Echo();
00049 };
00050
00051 class SyntaxError : public std::exception
00052 {
00053 private:
00054 std::string message;
00055 std::string echo;
00056 public:
00057 virtual const char* what() const throw() { return message.c_str(); }
00058 virtual ~SyntaxError() throw() {}
00059 std::string Message();
00060 SyntaxError(std::string,std::string);
00061 std::string Echo();
00062 };
00063
00064 class PreprocessorError : public std::exception
00065 {
00066 private:
00067 std::string echo;
00068 std::vector<std::string> files_not_found;
00069 std::string message;
00070 public:
00071 virtual const char* what() const throw() { return message.c_str(); }
00072 virtual ~PreprocessorError() throw() {}
00073 std::string Message();
00074 PreprocessorError(std::string,std::vector<std::string>);
00075 std::string partialEcho();
00076 };
00077
00078 class WriteError : public std::exception
00079 {
00080 private:
00081 std::string filename;
00082 std::string message;
00083 public:
00084 virtual const char* what() const throw() { return message.c_str(); }
00085 virtual ~WriteError() throw() {}
00086 std::string Message();
00087 std::string Filename();
00088 WriteError(std::string,std::string);
00089 };
00090
00091 }
00092
00093 #endif