00001
00002 #ifndef FTC_EXCEPTION_V1_04_01_H_
00003 #define FTC_EXCEPTION_V1_04_01_H_
00004
00005 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00006 # pragma once
00007 #endif
00008
00009 #include "ftc/ErrorCodes.h"
00010
00011 #include <string>
00012 #include <stdexcept>
00013
00014 namespace tecgraf { namespace ftc { namespace v1_04_01
00015 {
00019 class FTCException : public std::exception
00020 {
00021 public:
00029 FTCException( ErrorCodes::ErrorCode code, const std::string& msg, const std::string& location)
00030 : code(code), msg(msg), m_location(location)
00031 {
00032 }
00033
00037 virtual ~FTCException() throw() {}
00038
00044 char const* what() const throw()
00045 {
00046 return msg.c_str();
00047 }
00048
00054 const char* location() const
00055 {
00056 return m_location.c_str();
00057 }
00058
00064 ErrorCodes::ErrorCode error_code()
00065 {
00066 return code;
00067 }
00068
00069 protected:
00073 ErrorCodes::ErrorCode code;
00077 std::string msg;
00081 std::string m_location;
00082 };
00083
00088 class FileNotOpenException : public FTCException
00089 {
00090 public:
00097 explicit FileNotOpenException( const std::string& msg, const std::string& location )
00098 : FTCException(ErrorCodes::file_not_open, msg, location){}
00099 };
00100
00105 class MaxClientsReachedException : public FTCException
00106 {
00107 public:
00114 explicit MaxClientsReachedException( const std::string& msg, const std::string& location )
00115 : FTCException(ErrorCodes::max_clients_reached, msg, location){}
00116 };
00117
00122 class FileLockedException : public FTCException
00123 {
00124 public:
00131 explicit FileLockedException( const std::string& msg, const std::string& location )
00132 : FTCException(ErrorCodes::file_locked, msg, location){}
00133 };
00134
00139 class NoPermissionException : public FTCException
00140 {
00141 public:
00148 explicit NoPermissionException( const std::string& msg, const std::string& location )
00149 : FTCException(ErrorCodes::no_permission, msg, location){}
00150 };
00151
00156 class FileNotFoundException : public FTCException
00157 {
00158 public:
00165 explicit FileNotFoundException( const std::string& msg, const std::string& location )
00166 : FTCException(ErrorCodes::read_only, msg, location) {}
00167 };
00168
00173 class InvalidKeyException : public FTCException
00174 {
00175 public:
00182 explicit InvalidKeyException( const std::string& msg, const std::string& location )
00183 : FTCException(ErrorCodes::invalid_key, msg, location){}
00184 };
00185
00189 class FailureException : public FTCException
00190 {
00191 public:
00198 explicit FailureException( const std::string& msg, const std::string& location )
00199 : FTCException(ErrorCodes::failure, msg, location){}
00200 };
00201
00206 class ReadOnlyException : public FTCException
00207 {
00208 public:
00215 explicit ReadOnlyException( const std::string& msg, const std::string& location )
00216 : FTCException(ErrorCodes::read_only,msg,location){}
00217 };
00218
00223 class InvalidProtocolVersionException : public FTCException
00224 {
00225 public:
00232 explicit InvalidProtocolVersionException( const std::string& msg, const std::string& location )
00233 : FTCException(ErrorCodes::invalid_version, msg, location){}
00234 };
00235
00241 class EndOfFileException : public FTCException
00242 {
00243 public:
00250 explicit EndOfFileException( const std::string& msg, const std::string& location )
00251 : FTCException(ErrorCodes::end_of_file,msg, location){}
00252 };
00253
00258 class UnsupportedOperationException : public FTCException
00259 {
00260 public:
00267 explicit UnsupportedOperationException( const std::string& msg, const std::string& location )
00268 : FTCException(ErrorCodes::unsupported_operation, msg, location){}
00269 };
00270
00274 class IllegalStateException : public FTCException
00275 {
00276 public:
00283 explicit IllegalStateException( const std::string& msg, const std::string& location )
00284 : FTCException(ErrorCodes::invalid_protocol_message, msg, location) {}
00285 };
00286
00287 }}}
00288
00289 #endif
00290