00001
00002
00003
00004
00005
00010
00011 #ifndef FOUNTAIN_ERRORS_H__
00012 #define FOUNTAIN_ERRORS_H__
00013
00014 #include "define.h"
00015 #include <string>
00016 #include <stdexcept>
00017
00020 enum FountainErrorCode {
00021 invalidFountainErrorCode=-1,
00022
00023
00024 generalSuccess=0,
00025 helpReply=10,
00026 statusReply=20,
00027 subscriptionReply=30,
00028 notificationSuccess=35,
00029 registrationSuccess=40,
00030
00031
00032 generalWarning=100,
00033
00034
00035 hostnameFailure=212,
00036 connectionFailure=220,
00037 sendFailure=224,
00038 receiveFailure=226,
00039 connectionTimedOut=232,
00040 unexpectedEndOfFile=246,
00041
00042
00043 actionIncorrectError=312,
00044 missingRequiredElement=314,
00045 statusIncorrectError=321,
00046
00047
00048 authorizationFailure=440,
00049 fountainVersionNumberMismatch=450,
00050 fountainActorStringMismatch=451,
00051 fountainNodeIdentificationError=452,
00052
00053
00054 generalServerFailure=700,
00055 notSupportedFailure=710,
00056 notUnderstoodFailure=712,
00057 internalServerError=720,
00058 resourceUnavailableError=730,
00059 fountainTreeNotIdleError=750,
00060 fountainTreeAlreadyInRecovery=751,
00061 fountainRejoinMasterNode=752,
00062 fountainUnknownInternalFailure=799,
00063
00064
00065 unknownFailure=999
00066 };
00067
00070 class FountainException : public std::exception {
00071 private:
00073 FountainErrorCode code_;
00074
00076 std::string what_;
00077
00078 public:
00082 FountainException(const std::string& msg=std::string(), FountainErrorCode code=unknownFailure) throw();
00083
00087 FountainException(const char* msg, FountainErrorCode code=unknownFailure) throw();
00088
00090 virtual ~FountainException() throw();
00091
00094 FountainErrorCode getCode() const { return code_; };
00095
00097 const char* what() const throw() { return what_.c_str(); }
00098
00101 virtual bool isFatal() const { return false; }
00102 };
00103
00107 class FatalFountainException : public FountainException {
00108 public:
00112 FatalFountainException(const std::string& msg=std::string(), FountainErrorCode code=unknownFailure) throw();
00113
00117 FatalFountainException(const char* msg, FountainErrorCode code=unknownFailure) throw();
00118
00121 bool isFatal() const { return true; }
00122 };
00123
00124
00127 bool fountain_convert(const char* s, FountainErrorCode& t);
00128
00129 const char* fountain_convert(FountainErrorCode t);
00130
00131 #endif