Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

error.h File Reference

This file contains the module for error handling. More...

#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/types.h>

Go to the source code of this file.

Error Type Lookup

These functions lookup error types by name or by number.

GWENHYWFAR_API int GWEN_Error_FindType (const char *name)
GWENHYWFAR_API const char * GWEN_Error_GetTypename (int t)

Getters And Setters

These functions get and set parts of an ERRORCODE.

GWENHYWFAR_API int GWEN_Error_GetCode (GWEN_ERRORCODE c)
GWENHYWFAR_API int GWEN_Error_GetSeverity (GWEN_ERRORCODE c)
GWENHYWFAR_API int GWEN_Error_GetType (GWEN_ERRORCODE c)
GWENHYWFAR_API int GWEN_Error_IsCustom (GWEN_ERRORCODE c)
GWENHYWFAR_API int GWEN_Error_IsOk (GWEN_ERRORCODE c)
GWENHYWFAR_API GWEN_ERRORCODE GWEN_Error_new (int iscustom, int severity, int typ, int code)
GWENHYWFAR_API void GWEN_Error_SetCode (GWEN_ERRORCODE *c, int v)
GWENHYWFAR_API void GWEN_Error_SetIsCustom (GWEN_ERRORCODE *c, int iscustom)
GWENHYWFAR_API void GWEN_Error_SetSeverity (GWEN_ERRORCODE *c, int v)
GWENHYWFAR_API void GWEN_Error_SetType (GWEN_ERRORCODE *c, int v)

Simplified Error Codes

In most cases you only need a simplified error code (without severity information etc). For those cases the constructed error code can be turned into a simplified code.

GWENHYWFAR_API int GWEN_Error_GetSimpleCode (GWEN_ERRORCODE c)

Error Type Registration

These functions are used to allocate error types. Each module should allocate a type to allow descriptive error messages. Since function pointers are involved you should carefully register and unregister the error types.

GWENHYWFAR_API GWEN_ERRORCODE GWEN_Error_RegisterType (GWEN_ERRORTYPEREGISTRATIONFORM *tptr)
GWENHYWFAR_API GWEN_ERRORCODE GWEN_Error_UnregisterType (GWEN_ERRORTYPEREGISTRATIONFORM *tptr)

Verbosity

Composing error messages.

GWENHYWFAR_API int GWEN_Error_ToString (GWEN_ERRORCODE c, char *buffer, int bsize)

Error Type Registration Form

GWENHYWFAR_API void GWEN_ErrorType_free (GWEN_ERRORTYPEREGISTRATIONFORM *f)
GWENHYWFAR_API GWEN_ERRORMESSAGEPTR GWEN_ErrorType_GetMsgPtr (GWEN_ERRORTYPEREGISTRATIONFORM *f)
GWENHYWFAR_API GWEN_ERRORTYPEREGISTRATIONFORMGWEN_ErrorType_new ()
GWENHYWFAR_API void GWEN_ErrorType_SetMsgPtr (GWEN_ERRORTYPEREGISTRATIONFORM *f, GWEN_ERRORMESSAGEPTR msgptr)
GWENHYWFAR_API void GWEN_ErrorType_SetName (GWEN_ERRORTYPEREGISTRATIONFORM *f, const char *name)
GWENHYWFAR_API void GWEN_ErrorType_SetType (GWEN_ERRORTYPEREGISTRATIONFORM *f, int c)

Defines

#define GWEN_ERROR_ABORTED   (-2)
#define GWEN_ERROR_ALREADY_REGISTERED   (-58)
#define GWEN_ERROR_BAD_ADDRESS   (-41)
#define GWEN_ERROR_BAD_ADDRESS_FAMILY   (-48)
#define GWEN_ERROR_BAD_SIZE   (-60)
#define GWEN_ERROR_BAD_SOCKETTYPE   (-32)
#define GWEN_ERROR_BROKEN_PIPE   (-39)
#define GWEN_ERROR_BUFFER_OVERFLOW   (-42)
#define GWEN_ERROR_CLOSE   (-54)
#define GWEN_ERROR_COULD_NOT_LOAD   (-49)
#define GWEN_ERROR_COULD_NOT_REGISTER   2
#define GWEN_ERROR_COULD_NOT_RESOLVE   (-50)
#define GWEN_ERROR_COULD_NOT_UNREGISTER   3
#define GWEN_ERROR_CT_BAD_NAME   (-69)
#define GWEN_ERROR_CT_BAD_PIN   (-71)
#define GWEN_ERROR_CT_BAD_PIN_0_LEFT   (-72)
#define GWEN_ERROR_CT_BAD_PIN_1_LEFT   (-73)
#define GWEN_ERROR_CT_BAD_PIN_2_LEFT   (-74)
#define GWEN_ERROR_CT_DEFAULT_PIN   (-77)
#define GWEN_ERROR_CT_IO_ERROR   (-70)
#define GWEN_ERROR_CT_NO_KEY   (-75)
#define GWEN_ERROR_CT_NOT_IMPLEMENTED   (-67)
#define GWEN_ERROR_CT_NOT_SUPPORTED   (-68)
#define GWEN_ERROR_CT_REMOVED   (-76)
#define GWEN_ERROR_DECRYPT   (-63)
#define GWEN_ERROR_ENCRYPT   (-62)
#define GWEN_ERROR_EOF   (-57)
#define GWEN_ERROR_GENERIC   (-1)
#define GWEN_ERROR_HOST_NOT_FOUND   (-43)
#define GWEN_ERROR_IN_PROGRESS   (-35)
#define GWEN_ERROR_INTERRUPTED   (-37)
#define GWEN_ERROR_INVALID   (-6)
#define GWEN_ERROR_INVALID_BUFFERSIZE   4
#define GWEN_ERROR_MEMORY_FULL   (-40)
#define GWEN_ERROR_NO_ADDRESS   (-44)
#define GWEN_ERROR_NO_DATA   (-55)
#define GWEN_ERROR_NO_RECOVERY   (-45)
#define GWEN_ERROR_NOT_AVAILABLE   (-3)
#define GWEN_ERROR_NOT_FOUND   (-51)
#define GWEN_ERROR_NOT_OPEN   (-33)
#define GWEN_ERROR_NOT_REGISTERED   (-59)
#define GWEN_ERROR_OPEN   (-5)
#define GWEN_ERROR_PARTIAL   (-56)
#define GWEN_ERROR_READ   (-52)
#define GWEN_ERROR_SEVERITY_DEBUG   0
#define GWEN_ERROR_SEVERITY_ERR   3
#define GWEN_ERROR_SEVERITY_INFO   1
#define GWEN_ERROR_SEVERITY_WARN   2
#define GWEN_ERROR_SIGN   (-64)
#define GWEN_ERROR_SSL   (-66)
#define GWEN_ERROR_STARTUP   (-36)
#define GWEN_ERROR_TIMEOUT   (-34)
#define GWEN_ERROR_TRY_AGAIN   (-46)
#define GWEN_ERROR_TYPE_ERROR   0
#define GWEN_ERROR_UNKNOWN_DNS_ERROR   (-47)
#define GWEN_ERROR_UNSPECIFIED   1
#define GWEN_ERROR_UNSUPPORTED   (-38)
#define GWEN_ERROR_USER_ABORTED   (-4)
#define GWEN_ERROR_VERIFY   (-65)
#define GWEN_ERROR_WRITE   (-53)
#define GWEN_SUCCESS   0

Typedefs

typedef GWEN_TYPE_UINT32 GWEN_ERRORCODE
typedef const char *(* GWEN_ERRORMESSAGEPTR )(int c)
typedef GWEN_ERRORTYPEREGISTRATIONFORM GWEN_ERRORTYPEREGISTRATIONFORM

Functions

GWENHYWFAR_API int GWEN_ErrorType_GetType (GWEN_ERRORTYPEREGISTRATIONFORM *f)


Detailed Description

This file contains the module for error handling.


Typedef Documentation

typedef GWEN_TYPE_UINT32 GWEN_ERRORCODE
 

An error code is 32 bits long and has the following bit format:
Bit(s)Meaning
31-30 Severity (0-3)
29 Custom error
28 Reserved
27-16 Type (specifies the type of the error, such as "ERROR_CLASS_SOCKET", "ERROR_CLASS_TIME" etc)
15-0 Code (16 bit error code)


Function Documentation

GWENHYWFAR_API int GWEN_Error_FindType const char *  name  ) 
 

This function returns the type number for the given type name.

Returns:
type number (-1 on error)

GWENHYWFAR_API int GWEN_Error_GetCode GWEN_ERRORCODE  c  ) 
 

Returns the 16 bit error code value.

GWENHYWFAR_API int GWEN_Error_GetSeverity GWEN_ERRORCODE  c  ) 
 

Returns the severity of the error

GWENHYWFAR_API int GWEN_Error_GetSimpleCode GWEN_ERRORCODE  c  ) 
 

GWENHYWFAR_API int GWEN_Error_GetType GWEN_ERRORCODE  c  ) 
 

Returns the error type.

GWENHYWFAR_API const char* GWEN_Error_GetTypename int  t  ) 
 

Returns the name of the type referenced by the its type number. This function is used when composing a human readable error string.

Returns:
name of the type (0 on error)
Parameters:
t type number

GWENHYWFAR_API int GWEN_Error_IsCustom GWEN_ERRORCODE  c  ) 
 

Checks whether this is a custom error code (which means that the error type and code has to be handled differently. Such a code might be used in programs).

Returns:
!=0 if it is a custom code, 0 otherwise

GWENHYWFAR_API int GWEN_Error_IsOk GWEN_ERRORCODE  c  ) 
 

Checks whether the code really contains an error. If it contains a debug/info/warn code then it will be treaten as "ok".

Returns:
!=0 if ok, 0 if it really is an error

GWENHYWFAR_API GWEN_ERRORCODE GWEN_Error_new int  iscustom,
int  severity,
int  typ,
int  code
 

Creates an error code based on the arguments given

Returns:
error code based on the given arguments
Parameters:
iscustom if !=0, then this is a custom code. Such an error code can be used by applications. No module of this library will produce errors with this set, so you can use this to take advantage of the ERRORCODE management even without registering you own error type.
severity severity level of this code (might be simply a debug code, a warning, an information or an error)
typ type of this code. As you read above all errors are grouped into error types.
code error code. This needs only to be unique within the error type (in fact that was the reason to introduce the "error type")

GWENHYWFAR_API GWEN_ERRORCODE GWEN_Error_RegisterType GWEN_ERRORTYPEREGISTRATIONFORM tptr  ) 
 

Register an error type. This function is called by other modules to register a unique type value for itself.

Returns:
0 on error (success otherwise)

GWENHYWFAR_API void GWEN_Error_SetCode GWEN_ERRORCODE c,
int  v
 

Sets the error code.

GWENHYWFAR_API void GWEN_Error_SetIsCustom GWEN_ERRORCODE c,
int  iscustom
 

Sets the custom flag.

GWENHYWFAR_API void GWEN_Error_SetSeverity GWEN_ERRORCODE c,
int  v
 

Sets the severity level.

GWENHYWFAR_API void GWEN_Error_SetType GWEN_ERRORCODE c,
int  v
 

Sets the error type.

GWENHYWFAR_API int GWEN_Error_ToString GWEN_ERRORCODE  c,
char *  buffer,
int  bsize
 

Composes a human readable error string which dumps all parts of an ERRORCODE.

Returns:
1 detailed error message created. If some parts of the ERRORCODE could not be translated (e.g. unassigned type number etc) a 0 is returned.
Parameters:
c error code
buffer pointer to a buffer to receive the message
bsize size of that buffer in bytes

GWENHYWFAR_API GWEN_ERRORCODE GWEN_Error_UnregisterType GWEN_ERRORTYPEREGISTRATIONFORM tptr  ) 
 

When removing a module it should always unregister its assigned error type to avoid segfaultes (due to pointers pointing to nowhere).

Returns:
0 on error (success otherwise)

GWENHYWFAR_API void GWEN_ErrorType_free GWEN_ERRORTYPEREGISTRATIONFORM f  ) 
 

GWENHYWFAR_API GWEN_ERRORMESSAGEPTR GWEN_ErrorType_GetMsgPtr GWEN_ERRORTYPEREGISTRATIONFORM f  ) 
 

GWENHYWFAR_API GWEN_ERRORTYPEREGISTRATIONFORM* GWEN_ErrorType_new  ) 
 

GWENHYWFAR_API void GWEN_ErrorType_SetMsgPtr GWEN_ERRORTYPEREGISTRATIONFORM f,
GWEN_ERRORMESSAGEPTR  msgptr
 

GWENHYWFAR_API void GWEN_ErrorType_SetName GWEN_ERRORTYPEREGISTRATIONFORM f,
const char *  name
 

GWENHYWFAR_API void GWEN_ErrorType_SetType GWEN_ERRORTYPEREGISTRATIONFORM f,
int  c
 


Generated on Wed Oct 5 15:12:37 2005 for gwenhywfar by  doxygen 1.4.4