libxml2
|
Error handling. More...
Data Structures | |
struct | _xmlError |
An object containing information about an error. More... | |
Macros | |
#define | initGenericErrorDefaultFunc(h) xmlSetGenericErrorFunc(NULL, (h) ? *(h) : NULL) |
Set generic error callback. | |
#define | xmlLastError (*__xmlLastError()) |
Thread-local variable containing the last reported error. | |
#define | xmlGenericError (*__xmlGenericError()) |
Thread-local variable containing the generic error callback. | |
#define | xmlGenericErrorContext (*__xmlGenericErrorContext()) |
Thread-local variable containing user data for the generic error handler. | |
#define | xmlStructuredError (*__xmlStructuredError()) |
Thread-local variable containing the structured error callback. | |
#define | xmlStructuredErrorContext (*__xmlStructuredErrorContext()) |
Thread-local variable containing user data for the structured error handler. | |
Typedefs | |
typedef void(* | xmlGenericErrorFunc) (void *ctx, const char *msg,...) |
Generic error callback. | |
typedef void(* | xmlStructuredErrorFunc) (void *userData, const xmlError *error) |
Structured error callback receiving an xmlError. | |
Enumerations | |
enum | xmlErrorLevel |
Indicates the level of an error. More... | |
enum | xmlErrorDomain |
Indicates where an error may have come from. More... | |
enum | xmlParserErrors |
Error codes. More... | |
Functions | |
void | xmlSetGenericErrorFunc (void *ctx, xmlGenericErrorFunc handler) |
Set the thread-local "generic" handler and context for error messages. | |
void | xmlSetStructuredErrorFunc (void *ctx, xmlStructuredErrorFunc handler) |
It's recommended to use the per-context error handlers instead: | |
void | xmlParserError (void *ctx, const char *msg,...) |
This is the default SAX error handler, but it will never be called. | |
void | xmlParserWarning (void *ctx, const char *msg,...) |
This is the default SAX warning handler, but it will never be called. | |
void | xmlParserValidityError (void *ctx, const char *msg,...) |
This is the default validity error handler, but it will never be called. | |
void | xmlParserValidityWarning (void *ctx, const char *msg,...) |
This is the default validity warning handler, but it will never be called. | |
void | xmlParserPrintFileInfo (struct _xmlParserInput *input) |
Displays the associated file and line information for the current input. | |
void | xmlParserPrintFileContext (struct _xmlParserInput *input) |
Displays current context within the input content for error reporting. | |
void | xmlFormatError (const xmlError *err, xmlGenericErrorFunc channel, void *data) |
Report a formatted error to a printf-like callback. | |
const xmlError * | xmlGetLastError (void) |
Get the last error raised in this thread. | |
void | xmlResetLastError (void) |
Reset the last error to success. | |
const xmlError * | xmlCtxtGetLastError (void *ctx) |
Get the last error raised. | |
void | xmlCtxtResetLastError (void *ctx) |
Reset the last parser error to success. | |
void | xmlResetError (xmlError *err) |
Reset the error to success. | |
int | xmlCopyError (const xmlError *from, xmlError *to) |
Copy an error. | |
Error handling.
API for error reporting and callbacks.
#define initGenericErrorDefaultFunc | ( | h | ) | xmlSetGenericErrorFunc(NULL, (h) ? *(h) : NULL) |
Set generic error callback.
#define xmlGenericError (*__xmlGenericError()) |
Thread-local variable containing the generic error callback.
#define xmlGenericErrorContext (*__xmlGenericErrorContext()) |
Thread-local variable containing user data for the generic error handler.
#define xmlLastError (*__xmlLastError()) |
Thread-local variable containing the last reported error.
#define xmlStructuredError (*__xmlStructuredError()) |
Thread-local variable containing the structured error callback.
#define xmlStructuredErrorContext (*__xmlStructuredErrorContext()) |
Thread-local variable containing user data for the structured error handler.
typedef void(* xmlGenericErrorFunc) (void *ctx, const char *msg,...) |
Generic error callback.
ctx | user data |
msg | printf-like format string |
... | arguments to format |
typedef void(* xmlStructuredErrorFunc) (void *userData, const xmlError *error) |
Structured error callback receiving an xmlError.
userData | user provided data for the error callback |
error | the error being raised |
enum xmlErrorDomain |
Indicates where an error may have come from.
enum xmlErrorLevel |
enum xmlParserErrors |
Error codes.
Note that only some codes are documented.
Copy an error.
from | a source error |
to | a target error |
const xmlError * xmlCtxtGetLastError | ( | void * | ctx | ) |
Get the last error raised.
Note that the XML parser typically doesn't stop after encountering an error and will often report multiple errors. Most of the time, the last error isn't useful. Future versions might return the first parser error instead.
ctx | an XML parser context |
void xmlCtxtResetLastError | ( | void * | ctx | ) |
Reset the last parser error to success.
This does not change the well-formedness status.
ctx | an XML parser context |
void xmlFormatError | ( | const xmlError * | err, |
xmlGenericErrorFunc | channel, | ||
void * | data | ||
) |
Report a formatted error to a printf-like callback.
This can result in a verbose multi-line report including additional information from the parser context.
err | the error |
channel | callback |
data | user data for callback |
const xmlError * xmlGetLastError | ( | void | ) |
Get the last error raised in this thread.
void xmlParserError | ( | void * | ctx, |
const char * | msg, | ||
... | |||
) |
This is the default SAX error handler, but it will never be called.
If it isn't replaced by the user, errors will be handled by xmlFormatError.
Format an error message with additional detail from the parser context and print to generic error handler.
ctx | an XML parser context |
msg | printf-like format string |
... | arguments to format |
void xmlParserPrintFileContext | ( | struct _xmlParserInput * | input | ) |
Displays current context within the input content for error reporting.
input | an xmlParserInput input |
void xmlParserPrintFileInfo | ( | struct _xmlParserInput * | input | ) |
Displays the associated file and line information for the current input.
input | an xmlParserInput input |
void xmlParserValidityError | ( | void * | ctx, |
const char * | msg, | ||
... | |||
) |
This is the default validity error handler, but it will never be called.
If it isn't replaced by the user, errors will be handled by xmlFormatError.
Format an error message with additional detail from the parser context and print to generic error handler.
ctx | an XML parser context |
msg | printf-like format string |
... | arguments to format |
void xmlParserValidityWarning | ( | void * | ctx, |
const char * | msg, | ||
... | |||
) |
This is the default validity warning handler, but it will never be called.
If it isn't replaced by the user, warnings will be handled by xmlFormatError.
Format an warning message with additional detail from the parser context and print to generic error handler.
ctx | an XML parser context |
msg | printf-like format string |
... | arguments to format |
void xmlParserWarning | ( | void * | ctx, |
const char * | msg, | ||
... | |||
) |
This is the default SAX warning handler, but it will never be called.
If it isn't replaced by the user, warnings will be handled by xmlFormatError.
Format an warning message with additional detail from the parser context and print to generic error handler.
ctx | an XML parser context |
msg | printf-like format string |
... | arguments to format |
void xmlResetError | ( | xmlError * | err | ) |
Reset the error to success.
err | pointer to the error |
void xmlSetGenericErrorFunc | ( | void * | ctx, |
xmlGenericErrorFunc | handler | ||
) |
Set the thread-local "generic" handler and context for error messages.
The generic error handler will only receive fragments of error messages which should be concatenated or printed to a stream.
If handler is NULL, use the built-in default handler which prints to stderr.
Since this is a thread-local setting, it's a good idea to reset the error handler to its default value after collecting the errors you're interested in. To get the original values, you have to access xmlGenericError and xmlGenericErrorContext directly, making this function kind of useless.
For multi-threaded applications, this must be set separately for each thread.
ctx | the new error handling context |
handler | the new handler function |
void xmlSetStructuredErrorFunc | ( | void * | ctx, |
xmlStructuredErrorFunc | handler | ||
) |
It's recommended to use the per-context error handlers instead:
Set the thread-local "structured" handler and context for error messages. If handler is NULL, the error handler is deactivated.
The structured error handler takes precedence over "generic" handlers, even per-context generic handlers.
Since this is a thread-local setting, it's a good idea to reset the error handler to its default value after collecting the errors you're interested in. To get the original values, you have to access xmlStructuredError and xmlStructuredErrorContext directly, making this function kind of useless.
For multi-threaded applications, this must be set separately for each thread.
ctx | the new error handling context |
handler | the new handler function |