23#ifndef __STUMPLESS_ERROR_H
24#define __STUMPLESS_ERROR_H
28#include <stumpless/config.h>
38#define STUMPLESS_FOREACH_ERROR(ERROR) \
44 ERROR(STUMPLESS_ADDRESS_FAILURE, 0) \
46 ERROR(STUMPLESS_ARGUMENT_EMPTY, 1) \
48 ERROR(STUMPLESS_ARGUMENT_TOO_BIG, 2) \
54 ERROR(STUMPLESS_DUPLICATE_ELEMENT, 3) \
60 ERROR(STUMPLESS_ELEMENT_NOT_FOUND, 4) \
62 ERROR(STUMPLESS_FILE_OPEN_FAILURE, 5) \
64 ERROR(STUMPLESS_FILE_WRITE_FAILURE, 6) \
66 ERROR(STUMPLESS_INDEX_OUT_OF_BOUNDS, 7) \
68 ERROR(STUMPLESS_INVALID_FACILITY, 8) \
70 ERROR(STUMPLESS_INVALID_ID, 9) \
76 ERROR(STUMPLESS_INVALID_SEVERITY, 10) \
78 ERROR(STUMPLESS_MEMORY_ALLOCATION_FAILURE, 11) \
80 ERROR(STUMPLESS_NETWORK_PROTOCOL_UNSUPPORTED, 12) \
86 ERROR(STUMPLESS_PARAM_NOT_FOUND, 13) \
88 ERROR(STUMPLESS_SOCKET_BIND_FAILURE, 14) \
90 ERROR(STUMPLESS_SOCKET_CONNECT_FAILURE, 15) \
92 ERROR(STUMPLESS_SOCKET_FAILURE, 16) \
94 ERROR(STUMPLESS_SOCKET_SEND_FAILURE, 17) \
96 ERROR(STUMPLESS_STREAM_WRITE_FAILURE, 18) \
98 ERROR(STUMPLESS_TARGET_INCOMPATIBLE, 19) \
100 ERROR(STUMPLESS_TARGET_UNSUPPORTED, 20) \
102 ERROR(STUMPLESS_TRANSPORT_PROTOCOL_UNSUPPORTED, 21) \
104 ERROR(STUMPLESS_WINDOWS_EVENT_LOG_CLOSE_FAILURE, 22) \
106 ERROR(STUMPLESS_WINDOWS_EVENT_LOG_OPEN_FAILURE, 23) \
108 ERROR(STUMPLESS_INVALID_ENCODING, 24) \
110 ERROR(STUMPLESS_GETHOSTNAME_FAILURE, 25 ) \
116 ERROR(STUMPLESS_FUNCTION_TARGET_FAILURE, 26 ) \
122 ERROR( STUMPLESS_JOURNALD_FAILURE, 27 ) \
129 ERROR( STUMPLESS_WINDOWS_FAILURE, 28 ) \
135 ERROR( STUMPLESS_INVALID_PARAM_STRING, 29 ) \
141 ERROR( STUMPLESS_SQLITE3_BUSY, 30 ) \
147 ERROR( STUMPLESS_SQLITE3_CALLBACK_FAILURE, 31 ) \
153 ERROR( STUMPLESS_SQLITE3_FAILURE, 32 ) \
159 ERROR( STUMPLESS_NETWORK_CLOSED, 33 )
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
Definition config.h:31
STUMPLESS_PUBLIC_FUNCTION const struct stumpless_error * stumpless_get_error(void)
Retrieves the error encountered by the last library call.
STUMPLESS_PUBLIC_FUNCTION enum stumpless_error_id stumpless_get_error_id(const struct stumpless_error *err)
Gets the error id of the given error.
STUMPLESS_PUBLIC_FUNCTION void stumpless_set_error_stream(FILE *stream)
Sets the stream to write errors to.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_error_id_string(enum stumpless_error_id id)
Gets the error string of the given error id.
#define STUMPLESS_FOREACH_ERROR(ERROR)
A macro to implement error id enum and error string array.
Definition error.h:38
STUMPLESS_PUBLIC_FUNCTION FILE * stumpless_get_error_stream(void)
Gets the current stream that errors are written to.
STUMPLESS_PUBLIC_FUNCTION void stumpless_perror(const char *prefix)
Prints information about the current error to the error stream.
stumpless_error_id
An (enum) identifier of the types of errors that might be encountered.
Definition error.h:118
@ STUMPLESS_GENERATE_ENUM
A provided network address was not valid.
Definition error.h:119
STUMPLESS_PUBLIC_FUNCTION bool stumpless_has_error(void)
True if the last call to a stumpless function encountered an error.
Generic functionality to be used with STUMPLESS_FOREACH macros to allow for more generic definition o...
Information describing an error encountered by the library.
Definition error.h:126
int code
an error code possibly providing more information
Definition error.h:129
const char * message
specific details of the failure
Definition error.h:128
enum stumpless_error_id id
error family
Definition error.h:127
const char * code_type
a description of the error code
Definition error.h:130