Error

Error — Error handling

Synopsis

void                lt_error_clear                      (lt_error_t *error);
lt_bool_t           lt_error_is_set                     (lt_error_t *error,
                                                         lt_error_type_t type);
lt_error_t *        lt_error_new                        (void);
void                lt_error_print                      (lt_error_t *error,
                                                         lt_error_type_t type);
lt_error_t *        lt_error_ref                        (lt_error_t *error);
lt_error_t *        lt_error_set                        (lt_error_t **error,
                                                         lt_error_type_t type,
                                                         const char *message);
                    lt_error_t;
enum                lt_error_type_t;
void                lt_error_unref                      (lt_error_t *error);

Description

This section describes the error handling in this library.

Details

lt_error_clear ()

void                lt_error_clear                      (lt_error_t *error);

Clean up all of the errors in error.

error :

a lt_error_t

lt_error_is_set ()

lt_bool_t           lt_error_is_set                     (lt_error_t *error,
                                                         lt_error_type_t type);

Checks if error contains type of errors. if LT_ERR_ANY is set to type, all the types of the errors are targeted. otherwise the result is filtered out by type.

error :

a lt_error_t

type :

a lt_error_type_t

Returns :

TRUE if any, otherwise FALSE

lt_error_new ()

lt_error_t *        lt_error_new                        (void);

Creates lt_error_t object. this function is protected and not supposed to use in applications directly. Use lt_error_set().

Returns :

a newly allocated lt_error_t. it has to be freed with lt_error_unref(). [transfer full]

lt_error_print ()

void                lt_error_print                      (lt_error_t *error,
                                                         lt_error_type_t type);

Output the error messages in error according to type.

error :

a lt_error_t

type :

a lt_error_type_t

lt_error_ref ()

lt_error_t *        lt_error_ref                        (lt_error_t *error);

Inscreases the reference count of error.

error :

a lt_error_t

Returns :

the same error object. [transfer none]

lt_error_set ()

lt_error_t *        lt_error_set                        (lt_error_t **error,
                                                         lt_error_type_t type,
                                                         const char *message);

Sets the error into error according to the given parameters.

error :

a return location for a lt_error_t

type :

a lt_error_type_t

message :

the string format to output the error messages

Returns :

an instance of lt_error_t

lt_error_t

typedef struct _lt_error_t lt_error_t;

All the fields in the lt_error_t structure are private to the lt_error_t implementation.


enum lt_error_type_t

enum lt_error_type_t {
	LT_ERR_UNKNOWN = -1,
	LT_ERR_SUCCESS = 0,
	LT_ERR_OOM,
	LT_ERR_FAIL_ON_XML,
	LT_ERR_EOT,
	LT_ERR_FAIL_ON_SCANNER,
	LT_ERR_NO_TAG,
	LT_ERR_INVALID,
	LT_ERR_ANY
};

Error code used in this library.

LT_ERR_UNKNOWN

unknown error happened.

LT_ERR_SUCCESS

an operation is succeeded.

LT_ERR_OOM

Out of memory occurred.

LT_ERR_FAIL_ON_XML

an error happened in libxml2.

LT_ERR_EOT

No tokens to scan.

LT_ERR_FAIL_ON_SCANNER

an error happened in the scanner.

LT_ERR_NO_TAG

No tags to process.

LT_ERR_INVALID

Invalid operation.

LT_ERR_ANY

No real error, but just a flag to query all of errors or ask if any errors happen

lt_error_unref ()

void                lt_error_unref                      (lt_error_t *error);

Decreases the reference count of error. when its reference count drops to 0, the object is finalized (i.e. its memory is freed).

error :

a lt_error_t