stumpless 2.2.0
载入中...
搜索中...
未找到
error.h
浏览该文件的文档.
1/* SPDX-License-Identifier: Apache-2.0 */
2
3/*
4 * Copyright 2018-2024 Joel E. Anderson
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
23#ifndef __STUMPLESS_ERROR_H
24#define __STUMPLESS_ERROR_H
25
26#include <stdbool.h>
27#include <stdio.h>
28#include <stumpless/config.h>
29#include <stumpless/generator.h>
30
31# ifdef __cplusplus
32extern "C" {
33# endif
34
38#define STUMPLESS_FOREACH_ERROR(ERROR) \
39
43\
44 ERROR(STUMPLESS_ADDRESS_FAILURE, 0) \
45\
46 ERROR(STUMPLESS_ARGUMENT_EMPTY, 1) \
47\
48 ERROR(STUMPLESS_ARGUMENT_TOO_BIG, 2) \
49
53\
54 ERROR(STUMPLESS_DUPLICATE_ELEMENT, 3) \
55
59\
60 ERROR(STUMPLESS_ELEMENT_NOT_FOUND, 4) \
61\
62 ERROR(STUMPLESS_FILE_OPEN_FAILURE, 5) \
63\
64 ERROR(STUMPLESS_FILE_WRITE_FAILURE, 6) \
65\
66 ERROR(STUMPLESS_INDEX_OUT_OF_BOUNDS, 7) \
67\
68 ERROR(STUMPLESS_INVALID_FACILITY, 8) \
69\
70 ERROR(STUMPLESS_INVALID_ID, 9) \
71
75\
76 ERROR(STUMPLESS_INVALID_SEVERITY, 10) \
77\
78 ERROR(STUMPLESS_MEMORY_ALLOCATION_FAILURE, 11) \
79\
80 ERROR(STUMPLESS_NETWORK_PROTOCOL_UNSUPPORTED, 12) \
81
85\
86 ERROR(STUMPLESS_PARAM_NOT_FOUND, 13) \
87\
88 ERROR(STUMPLESS_SOCKET_BIND_FAILURE, 14) \
89\
90 ERROR(STUMPLESS_SOCKET_CONNECT_FAILURE, 15) \
91\
92 ERROR(STUMPLESS_SOCKET_FAILURE, 16) \
93\
94 ERROR(STUMPLESS_SOCKET_SEND_FAILURE, 17) \
95\
96 ERROR(STUMPLESS_STREAM_WRITE_FAILURE, 18) \
97\
98 ERROR(STUMPLESS_TARGET_INCOMPATIBLE, 19) \
99\
100 ERROR(STUMPLESS_TARGET_UNSUPPORTED, 20) \
101\
102 ERROR(STUMPLESS_TRANSPORT_PROTOCOL_UNSUPPORTED, 21) \
103\
104 ERROR(STUMPLESS_WINDOWS_EVENT_LOG_CLOSE_FAILURE, 22) \
105\
106 ERROR(STUMPLESS_WINDOWS_EVENT_LOG_OPEN_FAILURE, 23) \
107\
108 ERROR(STUMPLESS_INVALID_ENCODING, 24) \
109\
110 ERROR(STUMPLESS_GETHOSTNAME_FAILURE, 25 ) \
111
115\
116 ERROR(STUMPLESS_FUNCTION_TARGET_FAILURE, 26 ) \
117
121\
122 ERROR( STUMPLESS_JOURNALD_FAILURE, 27 ) \
123
129 ERROR( STUMPLESS_WINDOWS_FAILURE, 28 ) \
134\
135 ERROR( STUMPLESS_INVALID_PARAM_STRING, 29 ) \
136
140\
141 ERROR( STUMPLESS_SQLITE3_BUSY, 30 ) \
142
146\
147 ERROR( STUMPLESS_SQLITE3_CALLBACK_FAILURE, 31 ) \
148
152\
153 ERROR( STUMPLESS_SQLITE3_FAILURE, 32 ) \
154
158\
159 ERROR( STUMPLESS_NETWORK_CLOSED, 33 )
160
173};
174
175
179struct stumpless_error {
181 const char *message;
182 int code;
183 const char *code_type;
184};
185
219const struct stumpless_error *
220stumpless_get_error( void );
221
244stumpless_get_error_id( const struct stumpless_error *err );
245
268const char *
270
288FILE *
290
313bool
314stumpless_has_error( void );
315
347void
348stumpless_perror( const char *prefix );
349
372void
373stumpless_set_error_stream( FILE *stream );
374
375# ifdef __cplusplus
376} /* extern "C" */
377# endif
378
379#endif /* __STUMPLESS_ERROR_H */
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
定义 config.h:31
void stumpless_set_error_stream(FILE *stream)
Sets the stream to write errors to.
void stumpless_perror(const char *prefix)
Prints information about the current error to the error stream.
#define STUMPLESS_FOREACH_ERROR(ERROR)
A macro to implement error id enum and error string array.
定义 error.h:38
const struct stumpless_error * stumpless_get_error(void)
Retrieves the error encountered by the last library call.
const char * stumpless_get_error_id_string(enum stumpless_error_id id)
Gets the error string of the given error id.
bool stumpless_has_error(void)
True if the last call to a stumpless function encountered an error.
FILE * stumpless_get_error_stream(void)
Gets the current stream that errors are written to.
stumpless_error_id
An (enum) identifier of the types of errors that might be encountered.
定义 error.h:118
@ STUMPLESS_GENERATE_ENUM
A provided network address was not valid.
定义 error.h:119
enum stumpless_error_id stumpless_get_error_id(const struct stumpless_error *err)
Gets the error id of the given 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.
定义 error.h:126
int code
an error code possibly providing more information
定义 error.h:129
const char * message
specific details of the failure
定义 error.h:128
enum stumpless_error_id id
error family
定义 error.h:127
const char * code_type
a description of the error code
定义 error.h:130