squareball
0.2.0.43-8b14
A general-purpose library for C99
|
Error reporting infrastructure. More...
Go to the source code of this file.
Data Structures | |
struct | sb_error_type_t |
typedef char *(* | sb_error_to_string_func_t) (void *data) |
typedef struct _sb_error_t | sb_error_t |
sb_error_t * | sb_error_new_from_type (sb_error_type_t *type, void *data) |
const char * | sb_error_get_type_name (sb_error_t *err) |
const void * | sb_error_get_data (sb_error_t *err) |
const char * | sb_error_to_string (sb_error_t *err) |
void | sb_error_free (sb_error_t *err) |
Error reporting infrastructure.
This implementation is heavily inspired by Golang's error reporting. The main error object, that is used internally by squareball, and is available for users, is just a string. See squareball/sb-strerror.h.
This header provides all the infrastructure needed to manipulate error objects in a generic way, without caring about what is stored in the error object, and to create custom error types.
typedef struct _sb_error_t sb_error_t |
Opaque data structure that represents an error object.
typedef char*(* sb_error_to_string_func_t) (void *data) |
Function signature for the function that is used to convert a custom error data to string.
This should only be used when creating a custom error type.
data | A pointer to custom data stored in the object. |
void sb_error_free | ( | sb_error_t * | err | ) |
Function that frees memory allocated for an error object.
err | An error object. |
const void* sb_error_get_data | ( | sb_error_t * | err | ) |
Function that returns a pointer to data stored in an error object.
err | An error object. |
const char* sb_error_get_type_name | ( | sb_error_t * | err | ) |
Function that returns the name of the error type.
err | An error object. |
sb_error_t* sb_error_new_from_type | ( | sb_error_type_t * | type, |
void * | data | ||
) |
Function that creates a new error object from a custom error type and data.
type | A pointer to a custom data type (sb_error_type_t) object. |
data | A pointer to data object. |
const char* sb_error_to_string | ( | sb_error_t * | err | ) |
Function that returns a string representation of the data stored in an error object.
err | An error object. |