handlers.hpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Ifdefs
00010 *****************************************************************************/
00011 
00012 #ifndef ECL_ERRORS_HANDLERS_HPP_
00013 #define ECL_ERRORS_HANDLERS_HPP_
00014 
00015 /*****************************************************************************
00016 ** Includes
00017 *****************************************************************************/
00018 
00019 #include <ecl/config/macros.hpp>
00020 #include <cstring>
00021 #include <cstdio>
00022 #include "macros.hpp"
00023 #include "flags.hpp"
00024 
00025 /*****************************************************************************
00026 ** Namespaces
00027 *****************************************************************************/
00028 
00029 namespace ecl {
00030 
00058 class ecl_errors_PUBLIC Error {
00059 public:
00065         Error(const ErrorFlag& flag = UnknownError) : error_flag(flag) {}
00066         virtual ~Error() {}
00067 
00072         virtual ErrorFlag flag() const { return error_flag; }
00073         virtual void operator=(const ErrorFlag &error) { error_flag = error; }
00074 
00075 //      virtual void debug(const char* loc) {
00076 //              #if !defined(NDEBUG) && !defined(ECL_NDEBUG)
00077 //                      printf("%s - %s\n",loc,what());
00078 //              #endif
00079 //      }
00080 
00094         virtual void print(const char* loc) {
00095                 printf("%s - %s\n",loc,what());
00096         }
00097 
00103         virtual const char* what() const {
00104                 switch (error_flag) {
00105                         case (NoError) : { return noErrorString(); }
00106                         case (OutOfRangeError) : { return outOfRangeErrorString(); }
00107                         case (ConstructorError) : { return constructorErrorString(); }
00108                         case (DestructorError) : { return destructorErrorString(); }
00109                         case (ConversionError) : { return conversionErrorString(); }
00110                         case (OpenError) : { return openErrorString(); }
00111                         case (CloseError) : { return closeErrorString(); }
00112                         case (InvalidArgError) : { return invalidArgErrorString(); }
00113                         case (ConfigurationError) : { return configurationErrorString(); }
00114                         case (ConnectionError) : { return connectErrorString(); }
00115                         case (ReadError) : { return readErrorString(); }
00116                         case (WriteError) : { return writeErrorString(); }
00117                         case (NotInitialisedError) : { return notInitialisedErrorString(); }
00118                         case (PermissionsError) : { return permissionsErrorString(); }
00119                         case (MemoryError) : { return memoryErrorString(); }
00120                         case (UsageError) : { return usageErrorString(); }
00121                         case (RaiiError) : { return raiiErrorString(); }
00122                         case (ArgNotSupportedError) : { return argNotSupportedErrorString(); }
00123                         case (NotSupportedError) : { return notSupportedErrorString(); }
00124                         case (BusyError) : { return busyErrorString(); }
00125                         case (OutOfResourcesError) : { return outOfResourcesErrorString(); }
00126                         case (InterruptedError) : { return interruptedErrorString(); }
00127                         case (BlockingError) : { return blockingErrorString(); }
00128                         case (SystemFailureError) : { return systemFailureErrorString(); }
00129                         case (InvalidObjectError) : { return invalidObjectErrorString(); }
00130                         case (IsLockedError) : { return isLockedErrorString(); }
00131                         case (TimeOutError) : { return isTimeOutErrorString(); }
00132                         case (NotFoundError) : { return notFoundErrorString(); }
00133                         case (ConnectionRefusedError) : { return connectionRefusedString(); }
00134 
00135                         default : { return unknownErrorString(); } // also covers the 'UnknownError flag.
00136                 }
00137         }
00138 protected:
00139         virtual const char* noErrorString() const { return "No error."; }
00140         virtual const char* outOfRangeErrorString() const { return "Out of range error - tried to access beyond the range of the object (usually container)."; }
00141         virtual const char* constructorErrorString() const { return "The constructor did not produce a valid object."; }
00142         virtual const char* destructorErrorString() const { return "The destructor failed to self destruct."; }
00143         virtual const char* conversionErrorString() const { return "Conversion from one type to another failed."; }
00144         virtual const char* openErrorString() const { return "Could not open the requested object."; }
00145         virtual const char* closeErrorString() const { return "Could not close the requested object."; }
00146         virtual const char* invalidArgErrorString() const { return "One of the supplied input arguments was invalid."; }
00147         virtual const char* configurationErrorString() const { return "There was a configuration error."; }
00148         virtual const char* connectErrorString() const { return "Could not connect."; }
00149         virtual const char* readErrorString() const { return "Could not read from the object."; }
00150         virtual const char* writeErrorString() const { return "Could not write to the object."; }
00151         virtual const char* notInitialisedErrorString() const { return "The object has not been properly initialised yet."; }
00152         virtual const char* permissionsErrorString() const { return "The caller does not have the required permissions."; }
00153         virtual const char* memoryErrorString() const { return "There was a problem allocating the requested memory."; }
00154         virtual const char* usageErrorString() const { return "The object was used incorrectly."; }
00155         virtual const char* raiiErrorString() const { return "The object is pure RAII style and must be initialised correctly, you may not use the default constructor."; }
00156         virtual const char* argNotSupportedErrorString() const { return "The combination of input arguments is not supported on this platform."; }
00157         virtual const char* notSupportedErrorString() const { return "This operation is not supported on this platform."; }
00158         virtual const char* busyErrorString() const { return "Resources are busy, operation is not permitted"; }
00159         virtual const char* outOfResourcesErrorString() const { return "Out of resources, cannot proceed."; }
00160         virtual const char* interruptedErrorString() const { return "This operation was interrupted."; }
00161         virtual const char* blockingErrorString() const { return "A device marked as blocking, but used as non-blocking, or vice versa."; }
00162         virtual const char* systemFailureErrorString() const { return "A subsystem has failed mid operation."; }
00163         virtual const char* invalidObjectErrorString() const { return "Attempted to work on an invalid object."; }
00164         virtual const char* isLockedErrorString() const { return "Invalidates attempts to work further because an object is locked."; }
00165         virtual const char* isTimeOutErrorString() const { return "A timeout occured."; }
00166         virtual const char* notFoundErrorString() const { return "The resource could not be found."; }
00167         virtual const char* connectionRefusedString() const { return "The connection was refused by the listener at the other end of the connection."; }
00168         virtual const char* unknownErrorString() const { return "Unknown error."; }
00169 
00170         ErrorFlag error_flag;
00171 };
00172 
00173 
00174 } // namespace ecl
00175 
00176 #endif /* ECL_ERRORS_HANDLERS_HPP_ */


ecl_errors
Author(s): Daniel Stonier
autogenerated on Thu Jun 16 2016 09:47:14