squareball
0.2.0.31-03ae
A general-purpose library for C99
|
Error reporting infrastructure. More...
#include <stdarg.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | sb_error_t |
enum | { SB_ERROR_FILE_OPEN = -1, SB_ERROR_FILE_READ = -2, SB_ERROR_FILE_WRITE = -3, SB_ERROR_DIR_CREATE = -4, SB_ERROR_CONFIGPARSER = -10 } |
sb_error_t * | sb_error_new (int code, const char *msg) |
sb_error_t * | sb_error_new_printf (int code, const char *format,...) |
sb_error_t * | sb_error_new_printf_parser (int code, const char *src, size_t src_len, size_t current, const char *format,...) |
void | sb_error_free (sb_error_t *err) |
Error reporting infrastructure.
This implementation is meant to be simple and easy to use, without global variables, etc. If user needs something more advanced, like support to repeated error codes, splitted error types for each type of error, etc., such solution should be implemented in the application itself.
anonymous enum |
Internal error codes.
This is an enum with all error codes used by squareball library itself. They start from 262144 (0x1000000) to avoid conflicts with application error codes.
void sb_error_free | ( | sb_error_t * | err | ) |
Function that frees memory allocated for an error object.
err | An error object. |
sb_error_t* sb_error_new | ( | int | code, |
const char * | msg | ||
) |
Function that creates a new error object.
code | Error code. |
msg | Human-readable error message. |
sb_error_t* sb_error_new_printf | ( | int | code, |
const char * | format, | ||
... | |||
) |
Function that creates a new error object, with printf(3)-like message formatting.
code | Error code. |
format | Format for human-readable error message. |
... | One or more printf(3)-like parameters. |
sb_error_t* sb_error_new_printf_parser | ( | int | code, |
const char * | src, | ||
size_t | src_len, | ||
size_t | current, | ||
const char * | format, | ||
... | |||
) |
Function that creates a new error object, with printf(3)-like message formatting and parser current position details.
code | Error code. |
src | String with source that was being parsed. |
src_len | Source string size. |
current | Current parser position, stating from 0 . |
format | Format for human-readable error message. |
... | One or more printf(3)-like parameters. |