ERR: Remove ERR_put_func_error() and reimplement ERR_put_error() as a macro
[openssl.git] / doc / man3 / ERR_put_error.pod
1 =pod
2
3 =head1 NAME
4
5 ERR_raise, ERR_raise_data,
6 ERR_put_error, ERR_add_error_data, ERR_add_error_vdata
7 - record an error
8
9 =head1 SYNOPSIS
10
11  #include <openssl/err.h>
12
13  void ERR_raise(int lib, int reason);
14  void ERR_raise_data(int lib, int reason, const char *fmt, ...);
15
16  void ERR_add_error_data(int num, ...);
17  void ERR_add_error_vdata(int num, va_list arg);
18
19 Deprecated since OpenSSL 3.0:
20
21  void ERR_put_error(int lib, int func, int reason, const char *file, int line);
22
23 =head1 DESCRIPTION
24
25 ERR_raise() adds a new error to the thread's error queue.  The
26 error occured in the library B<lib> for the reason given by the
27 B<reason> code.  Furthermore, the name of the file, the line, and name
28 of the function where the error occured is saved with the error
29 record.
30
31 ERR_raise_data() does the same thing as ERR_raise(), but also lets the
32 caller specify additional information as a format string B<fmt> and an
33 arbitrary number of values, which are processed with L<BIO_snprintf(3)>.  
34
35 ERR_put_error() adds an error code to the thread's error queue. It
36 signals that the error of reason code B<reason> occurred in function
37 B<func> of library B<lib>, in line number B<line> of B<file>.
38 This function is usually called by a macro.
39
40 ERR_add_error_data() associates the concatenation of its B<num> string
41 arguments with the error code added last.
42 ERR_add_error_vdata() is similar except the argument is a B<va_list>.
43 Multiple calls to these functions append to the current top of the error queue.
44
45 L<ERR_load_strings(3)> can be used to register
46 error strings so that the application can a generate human-readable
47 error messages for the error code.
48
49 =head2 Reporting errors
50
51 =for comment TODO(3.0) should this be internal documentation?
52
53 Each sub-library has a specific macro XXXerr() that is used to report
54 errors. Its first argument is a function code B<XXX_F_...>, the second
55 argument is a reason code B<XXX_R_...>. Function codes are derived
56 from the function names; reason codes consist of textual error
57 descriptions. For example, the function ssl3_read_bytes() reports a
58 "handshake failure" as follows:
59
60  SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE);
61
62 Function and reason codes should consist of upper case characters,
63 numbers and underscores only. The error file generation script translates
64 function codes into function names by looking in the header files
65 for an appropriate function name, if none is found it just uses
66 the capitalized form such as "SSL3_READ_BYTES" in the above example.
67
68 The trailing section of a reason code (after the "_R_") is translated
69 into lower case and underscores changed to spaces.
70
71 Although a library will normally report errors using its own specific
72 XXXerr macro, another library's macro can be used. This is normally
73 only done when a library wants to include ASN1 code which must use
74 the ASN1err() macro.
75
76
77 =head1 RETURN VALUES
78
79 ERR_raise(), ERR_put_error(), ERR_add_error_data() and
80 ERR_add_error_vdata() return no values.
81
82 =head1 NOTES
83
84 ERR_raise() and ERR_put_error() are implemented as macros.
85
86 =head1 SEE ALSO
87
88 L<ERR_load_strings(3)>
89
90 =head1 COPYRIGHT
91
92 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
93
94 Licensed under the Apache License 2.0 (the "License").  You may not use
95 this file except in compliance with the License.  You can obtain a copy
96 in the file LICENSE in the source distribution or at
97 L<https://www.openssl.org/source/license.html>.
98
99 =cut