Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psErrorCodes.h

Go to the documentation of this file.
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.2 $ $Name: rel12 $
00010  *  @date $Date: 2006/06/14 22:09:33 $
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_BAD_FITS,
00044     PS_ERR_N_ERR_CLASSES               ///< end marker - should not be used as a true error
00045 } psErrorCode;
00046 
00047 /** An error code with description
00048  */
00049 typedef struct
00050 {
00051     psErrorCode code;                  ///< An error code
00052     const char *description;           ///< the associated description
00053 }
00054 psErrorDescription;
00055 
00056 /** Allocates a new psErrorDescription
00057  *
00058  *  @return psErrorDescription*        new psErrorDescription struct.
00059  */
00060 psErrorDescription* psErrorDescriptionAlloc(
00061     psErrorCode code,                  ///< An error code
00062     const char *description            ///< the associated description
00063 );
00064 
00065 /** Retrieves the description of an error code.
00066  *
00067  *  The routine psErrorCodeString returns the string associated with an error
00068  *  code.
00069  *
00070  *  @return const char*     the description associated with the given code.
00071  */
00072 const char *psErrorCodeString(
00073     psErrorCode code                   ///< the associated error code
00074 );
00075 
00076 /** Register an error code
00077  *
00078  *  Any project needed to use psLib must define the necessary error codes and
00079  *  associated message strings.  This function registers an array of error
00080  *  codes with the error handling subsystem.
00081  *
00082  */
00083 void psErrorRegister(
00084     const psErrorDescription* errors,  ///< Array of error codes to register
00085     int nerror                         ///< number of errors in input array
00086 );
00087 
00088 /** Clears error codes registered via psErrorRegister.
00089  *
00090  *  @return psBool    TRUE if given errorcode was removed, otherwise FALSE.
00091  */
00092 psBool p_psErrorUnregister(
00093     psErrorCode code                   ///< the error code to find and remove
00094 );
00095 
00096 /// @}
00097 
00098 #endif // #ifndef PS_ERROR_CODES_H

Generated on Mon Jul 3 14:13:44 2006 for Pan-STARRS Foundation Library by  doxygen 1.4.4