plibsys 0.0.5
perror.h
Go to the documentation of this file.
1/*
2 * The MIT License
3 *
4 * Copyright (C) 2016-2023 Alexander Saprykin <saprykin.spb@gmail.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * 'Software'), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
54#if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
55# error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
56#endif
57
58#ifndef PLIBSYS_HEADER_PERROR_H
59#define PLIBSYS_HEADER_PERROR_H
60
61#include <pmacros.h>
62#include <ptypes.h>
63#include <perrortypes.h>
64
66
68typedef struct PError_ PError;
69
76
86 pint native_code,
87 const pchar *message);
88
96
104
114
122
132
142 pint code,
143 pint native_code,
144 const pchar *message);
145
160 pint code,
161 pint native_code,
162 const pchar *message);
163
171 pint code);
172
180 pint native_code);
181
189 const pchar *message);
190
198
205
217
226
237
246
248
249#endif /* PLIBSYS_HEADER_PERROR_H */
P_LIB_API pint p_error_get_code(const PError *error)
Gets an error code.
P_LIB_API PError * p_error_new_literal(pint code, pint native_code, const pchar *message)
Initializes a new PError with data.
P_LIB_API void p_error_set_message(PError *error, const pchar *message)
Sets an error message.
P_LIB_API void p_error_set_last_net(pint code)
Sets the last network native error code.
P_LIB_API void p_error_set_code(PError *error, pint code)
Sets an error code.
struct PError_ PError
Opaque data structure for an error object.
Definition perror.h:68
P_LIB_API PError * p_error_new(void)
Initializes a new empty PError.
P_LIB_API pint p_error_get_last_system(void)
Gets the last system native error code.
P_LIB_API void p_error_set_error(PError *error, pint code, pint native_code, const pchar *message)
Sets error data.
P_LIB_API pint p_error_get_native_code(const PError *error)
Gets a platform native error code, if any.
P_LIB_API void p_error_set_error_p(PError **error, pint code, pint native_code, const pchar *message)
Sets error data through a double pointer.
P_LIB_API PError * p_error_copy(const PError *error)
Creates a copy of a PError object.
P_LIB_API void p_error_set_native_code(PError *error, pint native_code)
Sets a platform native error code.
P_LIB_API PErrorDomain p_error_get_domain(const PError *error)
Gets an error domain.
P_LIB_API pint p_error_get_last_net(void)
Gets the last network native error code.
P_LIB_API void p_error_free(PError *error)
Frees a previously initialized error object.
P_LIB_API void p_error_set_last_system(pint code)
Sets the last system native error code.
P_LIB_API void p_error_clear(PError *error)
Clears error data.
P_LIB_API const pchar * p_error_get_message(const PError *error)
Gets an error message.
Error data types.
enum PErrorDomain_ PErrorDomain
Enum with error domains.
Miscellaneous macros.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition pmacros.h:298
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS.
Definition pmacros.h:299
#define P_LIB_API
Exports a symbol from a shared library.
Definition pmacros.h:138
Types definitions.
char pchar
Type for a char.
Definition ptypes.h:116
int pint
Type for an int.
Definition ptypes.h:120