xref: /freebsd/crypto/openssl/doc/man3/ERR_put_error.pod (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1=pod
2
3=head1 NAME
4
5ERR_put_error, ERR_add_error_data, ERR_add_error_vdata - record an error
6
7=head1 SYNOPSIS
8
9 #include <openssl/err.h>
10
11 void ERR_put_error(int lib, int func, int reason, const char *file, int line);
12
13 void ERR_add_error_data(int num, ...);
14 void ERR_add_error_vdata(int num, va_list arg);
15
16=head1 DESCRIPTION
17
18ERR_put_error() adds an error code to the thread's error queue. It
19signals that the error of reason code B<reason> occurred in function
20B<func> of library B<lib>, in line number B<line> of B<file>.
21This function is usually called by a macro.
22
23ERR_add_error_data() associates the concatenation of its B<num> string
24arguments with the error code added last.
25ERR_add_error_vdata() is similar except the argument is a B<va_list>.
26
27L<ERR_load_strings(3)> can be used to register
28error strings so that the application can a generate human-readable
29error messages for the error code.
30
31=head2 Reporting errors
32
33Each sub-library has a specific macro XXXerr() that is used to report
34errors. Its first argument is a function code B<XXX_F_...>, the second
35argument is a reason code B<XXX_R_...>. Function codes are derived
36from the function names; reason codes consist of textual error
37descriptions. For example, the function ssl3_read_bytes() reports a
38"handshake failure" as follows:
39
40 SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE);
41
42Function and reason codes should consist of uppercase characters,
43numbers and underscores only. The error file generation script translates
44function codes into function names by looking in the header files
45for an appropriate function name, if none is found it just uses
46the capitalized form such as "SSL3_READ_BYTES" in the above example.
47
48The trailing section of a reason code (after the "_R_") is translated
49into lowercase and underscores changed to spaces.
50
51Although a library will normally report errors using its own specific
52XXXerr macro, another library's macro can be used. This is normally
53only done when a library wants to include ASN1 code which must use
54the ASN1err() macro.
55
56
57=head1 RETURN VALUES
58
59ERR_put_error() and ERR_add_error_data() return
60no values.
61
62=head1 SEE ALSO
63
64L<ERR_load_strings(3)>
65
66=head1 COPYRIGHT
67
68Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
69
70Licensed under the OpenSSL license (the "License").  You may not use
71this file except in compliance with the License.  You can obtain a copy
72in the file LICENSE in the source distribution or at
73L<https://www.openssl.org/source/license.html>.
74
75=cut
76