asdf/error.h¶
Here you can find the error codes returned by asdf_error_code (which itself is declared in asdf/file.h).
Public error codes for the libasdf error-handling API, and internal error reporting macros.
Error codes¶
-
enum asdf_error_code_t¶
Error codes set on an asdf_file_t or other context.
Retrieve with asdf_error_code. When the code is ASDF_ERR_SYSTEM, the original OS
errnovalue is available via asdf_error_errno.-
enumerator ASDF_ERR_NONE = 0¶
No error
-
enumerator ASDF_ERR_UNKNOWN_STATE¶
Unknown parser state
-
enumerator ASDF_ERR_STREAM_INIT_FAILED¶
Stream initialization failed
-
enumerator ASDF_ERR_STREAM_READ_ONLY¶
Attempted write to a read-only stream or file
-
enumerator ASDF_ERR_INVALID_ASDF_HEADER¶
Invalid ASDF file header
-
enumerator ASDF_ERR_UNEXPECTED_EOF¶
Unexpected end of file
-
enumerator ASDF_ERR_INVALID_BLOCK_HEADER¶
Invalid block header
-
enumerator ASDF_ERR_BLOCK_MAGIC_MISMATCH¶
Block magic bytes did not match
-
enumerator ASDF_ERR_YAML_PARSER_INIT_FAILED¶
YAML parser initialization failed
-
enumerator ASDF_ERR_YAML_PARSE_FAILED¶
YAML parsing failed
-
enumerator ASDF_ERR_OUT_OF_MEMORY¶
Out of memory
-
enumerator ASDF_ERR_SYSTEM¶
OS-level error; see asdf_error_errno for the original
errno
-
enumerator ASDF_ERR_INVALID_ARGUMENT¶
Invalid argument
When set with ASDF_ERROR_COMMON takes two parameters:
char *- the name of the function argument passed an invalid valuechar *- a string representation of the invalid value passed
-
enumerator ASDF_ERR_UNKNOWN_COMPRESSION¶
Unknown compression type
When set with ASDF_ERROR_COMMON takes one parameter:
char *- the unknown compression type string, NULL-terminated
-
enumerator ASDF_ERR_COMPRESSION_FAILED¶
Compression or decompression error
When set with ASDF_ERROR_COMMON takes one parameter:
char *- additional compression/decompression error details, typically passed from the underlying compression library or compressor extension.
-
enumerator ASDF_ERR_EXTENSION_NOT_FOUND¶
No serializer registered for extension
When set with ASDF_ERROR_COMMON takes one parameter:
char *- the key naming the extension (typically a YAML tag)
-
enumerator ASDF_ERR_OVER_LIMIT¶
A system limit has been reached
When set with ASDF_ERROR_COMMON takes one parameter:
char *- additional details of the limit that that was surpassed
-
enumerator ASDF_ERR_NONE = 0¶
Reporting errors¶
The following macros are intended for setting internal error states in libasdf. Normally these are meant for internal use, but are exposed in the public API for use by extension authors as well. Application code (outside libasdf) should not use these, as they set error codes in libasdf itself.
Each of these macros also causes a log message to be emitted at
ASDF_LOG_ERROR or greater if compiled with ASDF_LOG_ENABLED.
-
ASDF_ERROR_COMMON(obj, code, ...)¶
Set an error with a code from asdf_error_code_t; optional variadic args are the format parameters for the per-code format string, which depends on the error code (some do not take any parameters).
Note
These format strings are defined in the source at
src/error.c. The per-code parameters are noted in the per-code documentation at asdf_error_code_t as best as possible, though refer to the source as the final arbiter.- Parameters:
obj – The libasdf handle in which to record the error: an asdf_file_t*, or an asdf_value_t* (which records against its file).
code – The asdf_error_code_t to set
... – Error code-specific additional parameters
-
ASDF_ERROR_OOM(obj)¶
Special case for reporting a memory error (e.g. failed allocation)
This is roughly equivalent to setting
ASDF_ERROR_COMMON(obj, ASDF_ERR_OUT_OF_MEMORY)with some extra precautions taken; use this as a shortcut for allocation failure error paths.- Parameters:
obj – The libasdf handle in which to record the error: an asdf_file_t*, or an asdf_value_t* (which records against its file).
-
ASDF_ERROR_SYSTEM(obj, errnum)¶
Set a system (OS) error from an errno value
This sets an error in libasdf but with an error message derived from
strerror.- Parameters:
obj – The libasdf handle in which to record the error: an asdf_file_t*, or an asdf_value_t* (which records against its file).
errnum – An error, e.g. from a system call, retrieved from
errno