17 * Create a new user error. User errors are primarily intended to be used by
18 * lbx_file_ops callback functions, but can be used for any purpose.
20 * Returns a positive code on success (which can be subsequently passed to
21 * lbx_error_raise), or a negative value on failure.
23 int lbx_error_new(const char *str
);
26 * Signal an error. The given code is recorded for later retreival by
27 * lbx_error_get. Errors are reported on a first-in, first-out basis.
28 * Errors are stored in a ring buffer which can overflow, at which point
29 * the oldest unretrieved error will be deleted.
31 * Negative codes represent system errors. That is, the negation of some
32 * (positive) errno value as returned by a library function. If a positive
33 * code does not correspond to any error, nothing is recorded.
35 * Returns -1 if the error code was not valid, or if an unretreived code
36 * was deleted. Otherwise, this function returns 0.
38 int lbx_error_raise(int code
);
41 * Retrieves an error. The oldest reported error is removed from the buffer.
42 * If msg is not NULL, a pointer to a human-readable description of the error
45 * Returns the retrieved error code, or 0 if there were no errors.
47 int lbx_error_get(const char **msg
);
50 * Retrieves an error. This function is the same as lbx_error_get, except that
51 * the error code is not removed from the buffer and will be reported by a
52 * subsequent call to lbx_error_get or lbx_error_peek.
54 int lbx_error_peek(const char **msg
);
57 * Helper function for when you only care about the message.
59 static inline const char *lbx_errmsg(void)