FesaException.h
Go to the documentation of this file.00001
00002
00003 #ifndef _FESA_EXCEPTION_H_
00004 #define _FESA_EXCEPTION_H_
00005
00006 #include <fesa-core/Exception/FesaExceptionDef.h>
00007
00008 #include <cstdarg>
00009 #include <map>
00010 #include <stdexcept>
00011 #include <stdint.h>
00012 #include <string>
00013
00014 namespace fesa
00015 {
00016
00017
00018
00019
00020
00028 class FesaException : public std::exception
00029 {
00030 public:
00031
00036 FesaException();
00037
00046 FesaException(const std::string& file, int32_t lineNumber, const char* errorMessage, ...);
00047
00055 FesaException(const std::string& file, int32_t lineNumber, const std::string& message);
00056
00057
00058 virtual ~FesaException() throw();
00059
00063 const char* what() const throw();
00064
00069 const std::string& getMessage() const;
00070
00074 const std::string& getErrorCode();
00075
00079 const std::string& getFileName();
00080
00084 int32_t getLineNumber();
00085
00090 long getErrorCodeAsLong();
00091
00095 void preloadMessages();
00096
00097 protected:
00098
00102 void buildMessage(va_list vl);
00103
00107 std::string message_;
00108
00112 std::string errorCode_;
00113
00117 std::string file_;
00118
00122 int32_t lineNumber_;
00123
00128 static std::map<std::string, std::string> messages_;
00129
00130 static bool messagesLoaded_;
00131
00136 virtual void loadMessagesFile(const std::string& file);
00137
00138 };
00139
00140 inline const std::string& FesaException::getErrorCode()
00141 {
00142 return errorCode_;
00143 }
00144
00145 inline const std::string& FesaException::getFileName()
00146 {
00147 return file_;
00148 }
00149
00150 inline int32_t FesaException::getLineNumber()
00151 {
00152 return lineNumber_;
00153 }
00154
00155
00156
00157 class FesaBadConfigException: public FesaException
00158 {
00159 public:
00160
00169 FesaBadConfigException(const std::string& file, int32_t lineNumber, const char* errorMessage, ...);
00170
00171 virtual ~FesaBadConfigException() throw ();
00172
00173 };
00174
00175 class FesaIOException: public FesaException
00176 {
00177 public:
00178
00187 FesaIOException(const std::string& file, int32_t lineNumber, const char* errorMessage, ...);
00188
00189 virtual ~FesaIOException() throw ();
00190
00191 };
00192
00193 class FesaBadParameterException: public FesaException
00194 {
00195 public:
00196
00205 FesaBadParameterException(const std::string& file, int32_t lineNumber, const char* errorMessage, ...);
00206
00207 virtual ~FesaBadParameterException() throw ();
00208
00209 };
00210
00211 class FesaTypeMismatchException: public FesaException
00212 {
00213 public:
00214
00223 FesaTypeMismatchException(const std::string& file, int32_t lineNumber, const char* errorMessage, ...);
00224
00225 virtual ~FesaTypeMismatchException() throw ();
00226
00227 };
00228
00229 class FesaInvalidResourceException: public FesaException
00230 {
00231 public:
00232
00241 FesaInvalidResourceException(const std::string& file, int32_t lineNumber, const char* errorMessage, ...);
00242
00243 virtual ~FesaInvalidResourceException() throw ();
00244
00245 };
00246
00247 class FesaFileException: public FesaException
00248 {
00249 public:
00250
00259 FesaFileException(const std::string& file, int32_t lineNumber, const char* errorMessage, ...);
00260
00261 virtual ~FesaFileException() throw ();
00262
00263 };
00264
00265 }
00266
00267 #endif // _FESA_EXCEPTION_H_