Handling errors
Errors are reported by Cowl via return values (such as cowl_ret), or by returning NULL
on allocation errors. Sometimes this may not be enough, such as when reading ontology documents.
In these cases, Cowl supports a more detailed error reporting mechanism via the CowlError
type, whose instances are returned by functions such as cowl_reader_last_error().
-
struct CowlError
Error information.
Public Members
-
UString message
Error message, or
ustring_nullif not available.
-
UString message
-
CowlError cowl_error(cowl_ret code, char const *fmt, ...)
Creates a new error with the specified code and message.
Note
The returned object must be destroyed by calling
cowl_error_deinit.- Parameters:
code – Error code.
fmt – Error message format string, or NULL for no message.
... – Format string arguments.
- Returns:
Error object.
-
CowlError cowl_error_code(cowl_ret code)
Creates a new error with the specified code and no message.
Note
The returned object must be destroyed by calling
cowl_error_deinit.- Parameters:
code – Error code.
- Returns:
Error object.
-
bool cowl_error_has_message(CowlError const *error)
Checks if the error has a message.
- Parameters:
error – The error.
- Returns:
True if the error has a message, false otherwise.
-
bool cowl_error_has_loc(CowlError const *error)
Checks if the error has a location.
- Parameters:
error – The error.
- Returns:
True if the error has a location, false otherwise.
-
UString cowl_error_to_string(CowlError const *error)
Converts the error to a string.
See also
Note
The returned object must be destroyed by calling
ustring_deinit.- Parameters:
error – The error.
- Returns:
String representation of the error.