00001
00006 #ifndef EXCEPTIONS_H_
00007 #define EXCEPTIONS_H_
00008
00009 #include <sstream>
00010 #include <string>
00011
00012 using namespace std;
00013
00017 class Exception {
00018
00019 protected:
00020
00024 string message;
00025
00026 public:
00027
00033 Exception(string message) {
00034 this->message = message;
00035 }
00036
00042 string getMessage() {
00043 return message;
00044 }
00045
00046 protected:
00050 Exception() {
00051 }
00052
00053 };
00054
00058 class FileException: public Exception {
00059 public:
00063 FileException() :
00064 Exception() {
00065 }
00069 FileException(string message) :
00070 Exception(message) {
00071 }
00072 };
00073
00077 class FileContentException: public FileException {
00078
00079 public:
00083 FileContentException(string message, string filename, int line) {
00084 ostringstream s;
00085 s << message << " in file " << filename << " (line " << line << ")";
00086 this->message = s.str();
00087 }
00088
00089 };
00090
00094 class ConfigParseException: public FileContentException {
00095
00096 public:
00100 ConfigParseException(string message, string filename, int line) :
00101 FileContentException(message, filename, line) {
00102 }
00103
00104 };
00105
00109 class ConfigSemanticException: public FileContentException {
00110
00111 public:
00115 ConfigSemanticException(string message, string filename, int line) :
00116 FileContentException(message, filename, line) {
00117 }
00118 };
00119
00123 class FileNotFound: public FileException {
00124
00125 public:
00129 FileNotFound(string message) :
00130 FileException("File not found: \"" + message + "\"") {
00131 }
00132 };
00133
00137 class IOException: public FileException {
00138
00139 public:
00143 IOException(string filename) :
00144 FileException("IOException during reading file: " + filename) {
00145 }
00146 };
00147
00148 #endif