Skip to main content

Module errors

Module errors 

Source
Expand description

Error subsystem (§21, §85 Phase 1).

Implements the libxml2 error reporting infrastructure:

  • xmlError struct management
  • Error domain/code registry
  • Structured error callbacks (thread-local storage)
  • Generic error callbacks (thread-local storage)
  • Last-error tracking (thread-local xmlGetLastError, xmlResetLastError, xmlCopyError)
  • Error message formatting
  • xmlRaiseError() — the central error reporting function

§UPSTREAM-PARITY

libxml2 has a two-tier error system:

  1. Structured errorsxmlStructuredErrorFunc receives an xmlErrorPtr with all structured fields (domain, code, level, line, etc.)

  2. Generic errorsxmlGenericErrorFunc receives a formatted string (printf-style). This is the older system, still widely used.

Both systems coexist. When both handlers are set, both are called. The last error is stored thread-locally for retrieval via xmlGetLastError.

§Phase 1 status

Complete — all error functions are implemented. Variadic message formatting will be enhanced in Phase 2+.

Functions§

copy_error
Copy an error from one location to another.
format_error_message
Format an error message.
get_last_error
Get the last error for the current thread.
raise_error
Raise an error — the central error reporting function.
reset_error
Reset an error structure to its default state.
reset_last_error
Reset the last error for the current thread.
set_generic_error_func
Set the generic error handler.
set_structured_error_func
Set the structured error handler.