Error

Error — Error handling

Functions

Types and Values

Description

This section describes the error handling in this library.

Functions

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_ref ()

lt_error_t *
lt_error_ref (lt_error_t *error);

Inscreases the reference count of error .

Parameters

error

a lt_error_t

 

Returns

the same error object.

[transfer none]


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).

Parameters

error

a lt_error_t

 

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.

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

 

...

the parameters to insert into the format string

 

Returns

an instance of lt_error_t


lt_error_clear ()

void
lt_error_clear (lt_error_t *error);

Clean up all of the errors in error .

Parameters

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 .

Parameters

error

a lt_error_t

 

type

a lt_error_type_t

 

Returns

TRUE if any, otherwise FALSE


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 .

Parameters

error

a lt_error_t

 

type

a lt_error_type_t

 

Types and Values

enum lt_error_type_t

Error code used in this library.

Members

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_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.