23. October 2006
While trying to add import and export of .po files in glom I try to understand how libgettext-po handles erros. In gettext-po.h:
/* Signal a problem of the given severity.
MESSAGE and/or FILENAME + 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.
MESSAGE_TEXT is the problem description (if MULTILINE_P is true,
multiple lines of text, each terminated with a newline, otherwise
usually a single line).
Must not return if SEVERITY is PO_SEVERITY_FATAL_ERROR. */
void (*xerror) (int severity,
const char *filename, size_t lineno, size_t column,
int multiline_p, const char *message_text);
This is a callback passed to po_write_file which is called on failure. Hmm, so this method is required not to return if “SEVERITY is PO_SEVERITY_FATAL_ERROR”. How could I do this? Of course I could call exit() but that not really good. An application should usually not die if an error occours. FATAL error occours for example, if the file is not writeable.
The only solution that came into my mind yet was to start another thread that would simply exit if something goes wrong but that is really ugly. Anyone here with better ideas? Maybe I just miss the point.