Libical API Documentation
3.0
|
Error handling for libical. More...
Go to the source code of this file.
Macros | |
#define | ICAL_ERRORS_ARE_FATAL 0 |
Determines if all libical errors are fatal and lead to the process aborting. More... | |
#define | ICAL_SETERROR_ISFUNC |
#define | icalerrno (*(icalerrno_return())) |
Access the current icalerrno value. More... | |
#define | icalerror_assert(test, message) |
Assert with a message. More... | |
#define | icalerror_check_arg(test, arg) |
Checks the assertion test and raises error on failure. More... | |
#define | icalerror_check_arg_re(test, arg, error) |
Checks the assertion test and raises error on failure, returns error. More... | |
#define | icalerror_check_arg_rv(test, arg) |
Checks the assertion test and raises error on failure, returns void. More... | |
#define | icalerror_check_arg_rx(test, arg, x) |
Checks the assertion test and raises error on failure, returns x. More... | |
#define | icalerror_check_arg_rz(test, arg) |
Checks the assertion test and raises error on failure, returns 0. More... | |
#define | icalerror_check_component_type(value, type) ; |
#define | icalerror_check_parameter_type(value, type) ; |
#define | icalerror_check_property_type(value, type) ; |
#define | icalerror_check_value_type(value, type) ; |
#define | icalerror_warn(message) {fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, message);} |
Prints a formatted warning message to stderr. More... | |
Typedefs | |
typedef enum icalerrorenum | icalerrorenum |
typedef enum icalerrorstate | icalerrorstate |
Enumerations | |
enum | icalerrorenum { ICAL_NO_ERROR = 0, ICAL_BADARG_ERROR, ICAL_NEWFAILED_ERROR, ICAL_ALLOCATION_ERROR, ICAL_MALFORMEDDATA_ERROR, ICAL_PARSE_ERROR, ICAL_INTERNAL_ERROR, ICAL_FILE_ERROR, ICAL_USAGE_ERROR, ICAL_UNIMPLEMENTED_ERROR, ICAL_UNKNOWN_ERROR } |
Represents the different types of errors that can be triggered in libical. More... | |
enum | icalerrorstate { ICAL_ERROR_FATAL, ICAL_ERROR_NONFATAL, ICAL_ERROR_DEFAULT, ICAL_ERROR_UNKNOWN } |
Determine if an error is fatal or non-fatal. More... | |
Functions | |
void | ical_bt (void) |
Prints backtrace. More... | |
icalerrorenum * | icalerrno_return (void) |
Returns the current icalerrno value. More... | |
void | icalerror_clear_errno (void) |
Resets icalerrno to ICAL_NO_ERROR. More... | |
void | icalerror_crash_here (void) |
Triggered to abort the process. More... | |
icalerrorenum | icalerror_error_from_string (const char *str) |
Reads an error from a string. More... | |
icalerrorstate | icalerror_get_error_state (icalerrorenum error) |
Gets the error state (severity) for a given error. More... | |
int | icalerror_get_errors_are_fatal (void) |
Determine if errors are fatal. More... | |
const char * | icalerror_perror (void) |
Returns the description string for the current error in icalerrno. More... | |
void | icalerror_restore (const char *error, icalerrorstate es) |
void | icalerror_set_errno (icalerrorenum x) |
Sets the icalerrno to a given error. More... | |
void | icalerror_set_error_state (icalerrorenum error, icalerrorstate state) |
Sets the icalerrorstate for a given icalerrorenum error. More... | |
void | icalerror_set_errors_are_fatal (int fatal) |
Change if errors are fatal. More... | |
void | icalerror_stop_here (void) |
Triggered before any error is called. More... | |
const char * | icalerror_strerror (icalerrorenum e) |
Finds the description string for error. More... | |
icalerrorstate | icalerror_supress (const char *error) |
Suppresses a given error. More... | |
Error handling for libical.
Most routines will set the global error value icalerrno on errors. This variable is an enumeration; permissible values can be found in icalerror.h. If the routine returns an enum icalerrorenum, then the return value will be the same as icalerrno. You can use icalerror_strerror() to get a string that describes the error, or icalerror_perror() to get a string describing the current error set in icalerrno.
#define ICAL_ERRORS_ARE_FATAL 0 |
Determines if all libical errors are fatal and lead to the process aborting.
If set to 1, all libical errors are fatal and lead to the process aborting upon encountering on. Otherwise, errors are nonfatal.
Can be checked with libical_get_errors_are_fatal().
#define icalerrno (*(icalerrno_return())) |
#define icalerror_assert | ( | test, | |
message | |||
) |
Assert with a message.
test | The assertion to test |
message | The message to print on failure of assertion |
Tests the given assertion test, and if it fails, prints the message given on stderr as a warning and aborts the process. This only works if ICAL_ERRORS_ARE_FATAL is true, otherwise does nothing.
#define icalerror_check_arg | ( | test, | |
arg | |||
) |
Checks the assertion test and raises error on failure.
test | The assertion to check |
arg | The argument involved (as a string) |
This function checks the assertion test, which is used to test if the parameter arg is correct. If the assertion fails, it sets icalerrno to ICAL_BADARG_ERROR.
#define icalerror_check_arg_re | ( | test, | |
arg, | |||
error | |||
) |
Checks the assertion test and raises error on failure, returns error.
test | The assertion to check |
arg | The argument involved (as a string) |
error | What to return on error |
This function checks the assertion test, which is used to test if the parameter arg is correct. If the assertion fails, it aborts the process with assert(0)
and causes the enclosing function to return error.
#define icalerror_check_arg_rv | ( | test, | |
arg | |||
) |
Checks the assertion test and raises error on failure, returns void.
test | The assertion to check |
arg | The argument involved (as a string) |
This function checks the assertion test, which is used to test if the parameter arg is correct. If the assertion fails, it sets icalerrno to ICAL_BADARG_ERROR and causes the enclosing function to return void
.
#define icalerror_check_arg_rx | ( | test, | |
arg, | |||
x | |||
) |
Checks the assertion test and raises error on failure, returns x.
test | The assertion to check |
arg | The argument involved (as a string) |
x | What to return on error |
This function checks the assertion test, which is used to test if the parameter arg is correct. If the assertion fails, it sets icalerrno to ICAL_BADARG_ERROR and causes the enclosing function to return x.
#define icalerror_check_arg_rz | ( | test, | |
arg | |||
) |
Checks the assertion test and raises error on failure, returns 0.
test | The assertion to check |
arg | The argument involved (as a string) |
This function checks the assertion test, which is used to test if the parameter arg is correct. If the assertion fails, it sets icalerrno to ICAL_BADARG_ERROR and causes the enclosing function to return 0
.
#define icalerror_warn | ( | message | ) | {fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, message);} |
Prints a formatted warning message to stderr.
message | Warning message to print |
enum icalerrorenum |
Represents the different types of errors that can be triggered in libical.
Each of these values represent a different type of error, which is stored in icalerrno on exit of the library function (or can be returned, but if it is, icalerrno is also set).
enum icalerrorstate |
void ical_bt | ( | void | ) |
icalerrorenum* icalerrno_return | ( | void | ) |
Returns the current icalerrno value.
Yields a pointer to the current icalerrno value. This can be used to access (read from and write to) it.
void icalerror_clear_errno | ( | void | ) |
Resets icalerrno to ICAL_NO_ERROR.
void icalerror_crash_here | ( | void | ) |
Triggered to abort the process.
This routine is called to abort the process in the case of an error.
icalerrorenum icalerror_error_from_string | ( | const char * | str | ) |
Reads an error from a string.
str | The error name string |
icalerrorstate icalerror_get_error_state | ( | icalerrorenum | error | ) |
Gets the error state (severity) for a given error.
error | The error to examine |
int icalerror_get_errors_are_fatal | ( | void | ) |
Determine if errors are fatal.
const char* icalerror_perror | ( | void | ) |
Returns the description string for the current error in icalerrno.
void icalerror_restore | ( | const char * | error, |
icalerrorstate | es | ||
) |
Assigns the given error the given icalerrorstate (severity).
error | The error in question |
es | The icalerrorstate (severity) to set it to |
Calling the function changes the icalerrorstate of the given error.
void icalerror_set_errno | ( | icalerrorenum | x | ) |
Sets the icalerrno to a given error.
x | The error to set icalerrno to |
Sets icalerrno to the error given in x. Additionally, if the error is an ICAL_ERROR_FATAL or if it's an ICAL_ERROR_DEFAULT and ICAL_ERRORS_ARE_FATAL is true, it prints a warning to stderr and aborts the process.
void icalerror_set_error_state | ( | icalerrorenum | error, |
icalerrorstate | state | ||
) |
Sets the icalerrorstate for a given icalerrorenum error.
error | The error to change |
state | The new error state of the error |
Sets the severity of a given error. For example, it can be used to set the severity of an ICAL_PARSE_ERROR to be an ICAL_ERROR_NONFATAL.
void icalerror_set_errors_are_fatal | ( | int | fatal | ) |
Change if errors are fatal.
fatal | If true, libical aborts after a call to icalerror_set_error() |
void icalerror_stop_here | ( | void | ) |
Triggered before any error is called.
This routine is called before any error is triggered. It is called by icalerror_set_errno(), so it does not appear in all of the macros below.
This routine can be used while debugging by setting a breakpoint here.
const char* icalerror_strerror | ( | icalerrorenum | e | ) |
Finds the description string for error.
e | The type of error that occurred |
icalerrorstate icalerror_supress | ( | const char * | error | ) |
Suppresses a given error.
error | The name of the error to suppress |
Calling this function causes the given error to be listed as ICAL_ERROR_NONFATAL, and thus suppressed. Error states can be restored with icalerror_restore().