Next: , Up: Writing your own programs that process PO files   [Contents][Index]


9.13.1 Error Handling

Error management is performed through callbacks provided by the user of the library. They are provided through a parameter with the following type:

Data Type: struct po_xerror_handler

Its pointer is defined as po_xerror_handler_t. Contains two fields, xerror and xerror2, with the following function signatures.

Function: void xerror (int severity, po_message_t message, const char *filename, size_t lineno, size_t column, int multiline_p, const char *message_text)

This function is called to signal a problem of the given severity. It must not return if severity is PO_SEVERITY_FATAL_ERROR.

message_text is the problem description. When multiline_p is true, it can contain multiple lines of text, each terminated with a newline, otherwise a single line.

message and/or filename and lineno indicate where the problem occurred:

  • If filename is NULL, filename and lineno and column should be ignored.
  • If lineno is (size_t)(-1), lineno and column should be ignored.
  • If column is (size_t)(-1), it should be ignored.
Function: void xerror2 (int severity, po_message_t message1, const char *filename1, size_t lineno1, size_t column1, int multiline_p1, const char *message_text1, po_message_t message2, const char *filename2, size_t lineno2, size_t column2, int multiline_p2, const char *message_text2)

This function is called to signal a problem of the given severity that refers to two messages. It must not return if severity is PO_SEVERITY_FATAL_ERROR.

It is similar to two calls to xerror. If possible, an ellipsis can be appended to message_text1 and prepended to message_text2.