00001 /** @file psErrorCodes.h 00002 * 00003 * @brief Contains the error codes for the error classes 00004 * 00005 * @ingroup ErrorHandling 00006 * 00007 * @author Robert DeSonia, MHPCC 00008 * 00009 * @version $Revision: 1.1.1.1 $ $Name: $ 00010 * @date $Date: 2005/09/14 20:42:48 $ 00011 * 00012 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00013 */ 00014 00015 #ifndef PS_ERROR_CODES_H 00016 #define PS_ERROR_CODES_H 00017 00018 #include "psType.h" 00019 00020 /** @addtogroup ErrorHandling 00021 * @{ 00022 */ 00023 00024 /** enumeration of the static error code classes 00025 */ 00026 typedef enum { 00027 PS_ERR_NONE = 0, ///< not an error 00028 PS_ERR_BASE = 256, 00029 /**< base error. Any psErrorCode less than this should be taken to be 00030 * valid values of errno 00031 */ 00032 PS_ERR_UNKNOWN, 00033 PS_ERR_IO, 00034 PS_ERR_LOCATION_INVALID, 00035 PS_ERR_MEMORY_CORRUPTION, 00036 PS_ERR_MEMORY_DEREF_USAGE, 00037 PS_ERR_BAD_PARAMETER_VALUE, 00038 PS_ERR_BAD_PARAMETER_TYPE, 00039 PS_ERR_BAD_PARAMETER_NULL, 00040 PS_ERR_BAD_PARAMETER_SIZE, 00041 PS_ERR_UNEXPECTED_NULL, 00042 PS_ERR_OS_CALL_FAILED, 00043 PS_ERR_N_ERR_CLASSES ///< end marker - should not be used as a true error 00044 } psErrorCode; 00045 00046 /** An error code with description 00047 */ 00048 typedef struct 00049 { 00050 psErrorCode code; ///< An error code 00051 const char *description; ///< the associated description 00052 } 00053 psErrorDescription; 00054 00055 /** Allocates a new psErrorDescription 00056 * 00057 * @return psErrorDescription* new psErrorDescription struct. 00058 */ 00059 psErrorDescription* psErrorDescriptionAlloc( 00060 psErrorCode code, ///< An error code 00061 const char *description ///< the associated description 00062 ); 00063 00064 /** Retrieves the description of an error code. 00065 * 00066 * The routine psErrorCodeString returns the string associated with an error 00067 * code. 00068 * 00069 * @return const char* the description associated with the given code. 00070 */ 00071 const char *psErrorCodeString( 00072 psErrorCode code ///< the associated error code 00073 ); 00074 00075 /** Register an error code 00076 * 00077 * Any project needed to use psLib must define the necessary error codes and 00078 * associated message strings. This function registers an array of error 00079 * codes with the error handling subsystem. 00080 * 00081 */ 00082 void psErrorRegister( 00083 const psErrorDescription* errors, ///< Array of error codes to register 00084 psS32 nerror ///< number of errors in input array 00085 ); 00086 00087 /** Clears error codes registered via psErrorRegister. 00088 * 00089 * @return psBool TRUE if given errorcode was removed, otherwise FALSE. 00090 */ 00091 psBool p_psErrorUnregister( 00092 psErrorCode code ///< the error code to find and remove 00093 ); 00094 00095 /// @} 00096 00097 #endif // #ifndef PS_ERROR_CODES_H
1.4.2