1ERR_GET_ERROR(3ossl) OpenSSL ERR_GET_ERROR(3ossl)
2
3
4
6 ERR_get_error, ERR_peek_error, ERR_peek_last_error, ERR_get_error_line,
7 ERR_peek_error_line, ERR_peek_last_error_line, ERR_peek_error_func,
8 ERR_peek_last_error_func, ERR_peek_error_data,
9 ERR_peek_last_error_data, ERR_get_error_all, ERR_peek_error_all,
10 ERR_peek_last_error_all, ERR_get_error_line_data,
11 ERR_peek_error_line_data, ERR_peek_last_error_line_data - obtain error
12 code and data
13
15 #include <openssl/err.h>
16
17 unsigned long ERR_get_error(void);
18 unsigned long ERR_peek_error(void);
19 unsigned long ERR_peek_last_error(void);
20
21 unsigned long ERR_peek_error_line(const char **file, int *line);
22 unsigned long ERR_peek_last_error_line(const char **file, int *line);
23
24 unsigned long ERR_peek_error_func(const char **func);
25 unsigned long ERR_peek_last_error_func(const char **func);
26
27 unsigned long ERR_peek_error_data(const char **data, int *flags);
28 unsigned long ERR_peek_last_error_data(const char **data, int *flags);
29
30 unsigned long ERR_get_error_all(const char **file, int *line,
31 const char **func,
32 const char **data, int *flags);
33 unsigned long ERR_peek_error_all(const char **file, int *line,
34 const char **func,
35 const char **data, int *flags);
36 unsigned long ERR_peek_last_error_all(const char **file, int *line,
37 const char *func,
38 const char **data, int *flags);
39
40 The following functions have been deprecated since OpenSSL 3.0, and can
41 be hidden entirely by defining OPENSSL_API_COMPAT with a suitable
42 version value, see openssl_user_macros(7):
43
44 unsigned long ERR_get_error_line(const char **file, int *line);
45 unsigned long ERR_get_error_line_data(const char **file, int *line,
46 const char **data, int *flags);
47 unsigned long ERR_peek_error_line_data(const char **file, int *line,
48 const char **data, int *flags);
49 unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
50 const char **data, int *flags);
51
53 ERR_get_error() returns the earliest error code from the thread's error
54 queue and removes the entry. This function can be called repeatedly
55 until there are no more error codes to return.
56
57 ERR_peek_error() returns the earliest error code from the thread's
58 error queue without modifying it.
59
60 ERR_peek_last_error() returns the latest error code from the thread's
61 error queue without modifying it.
62
63 See ERR_GET_LIB(3) for obtaining further specific information such as
64 the reason of the error, and ERR_error_string(3) for human-readable
65 error messages.
66
67 ERR_get_error_all() is the same as ERR_get_error(), but on success it
68 additionally stores the filename, line number and function where the
69 error occurred in *file, *line and *func, and also extra text and flags
70 in *data, *flags. If any of those parameters are NULL, it will not be
71 changed. An unset filename is indicated as "", i.e. an empty string.
72 An unset line number is indicated as 0. An unset function name is
73 indicated as "", i.e. an empty string.
74
75 A pointer returned this way by these functions and the ones below is
76 valid until the respective entry is overwritten in the error queue.
77
78 ERR_peek_error_line() and ERR_peek_last_error_line() are the same as
79 ERR_peek_error() and ERR_peek_last_error(), but on success they
80 additionally store the filename and line number where the error
81 occurred in *file and *line, as far as they are not NULL. An unset
82 filename is indicated as "", i.e., an empty string. An unset line
83 number is indicated as 0.
84
85 ERR_peek_error_func() and ERR_peek_last_error_func() are the same as
86 ERR_peek_error() and ERR_peek_last_error(), but on success they
87 additionally store the name of the function where the error occurred in
88 *func, unless it is NULL. An unset function name is indicated as "".
89
90 ERR_peek_error_data() and ERR_peek_last_error_data() are the same as
91 ERR_peek_error() and ERR_peek_last_error(), but on success they
92 additionally store additional data and flags associated with the error
93 code in *data and *flags, as far as they are not NULL. Unset data is
94 indicated as "". In this case the value given for the flag is
95 irrelevant (and equals 0). *data contains a string if
96 *flags&ERR_TXT_STRING is true.
97
98 ERR_peek_error_all() and ERR_peek_last_error_all() are combinations of
99 all of the above.
100
101 ERR_get_error_line(), ERR_get_error_line_data(),
102 ERR_peek_error_line_data() and ERR_peek_last_error_line_data() are
103 older variants of ERR_get_error_all(), ERR_peek_error_all() and
104 ERR_peek_last_error_all(), and may give confusing results. They should
105 no longer be used and are therefore deprecated.
106
107 An application MUST NOT free the *data pointer (or any other pointers
108 returned by these functions) with OPENSSL_free() as freeing is handled
109 automatically by the error library.
110
112 The error code, or 0 if there is no error in the queue.
113
115 ERR_error_string(3), ERR_GET_LIB(3)
116
118 ERR_peek_error_func(), ERR_peek_last_error_func(),
119 ERR_peek_error_data(), ERR_peek_last_error_data(), ERR_peek_error_all()
120 and ERR_peek_last_error_all() were added in OpenSSL 3.0.
121
122 ERR_get_error_line(), ERR_get_error_line_data(),
123 ERR_peek_error_line_data() and ERR_peek_last_error_line_data() became
124 deprecated in OpenSSL 3.0.
125
127 Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
128
129 Licensed under the Apache License 2.0 (the "License"). You may not use
130 this file except in compliance with the License. You can obtain a copy
131 in the file LICENSE in the source distribution or at
132 <https://www.openssl.org/source/license.html>.
133
134
135
1363.0.5 2022-11-01 ERR_GET_ERROR(3ossl)