d9bbba99a06ac10b2d6e43d4f4c00a76d1d32ce8
[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_put_func_error,
7 ERR_add_error_data, ERR_add_error_vdata - 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_put_error(int lib, int func, int reason, const char *file, int line);
17  void ERR_put_func_error(int lib, const char *func, int reason,
18                          const char *file, int line);
19
20  void ERR_add_error_data(int num, ...);
21  void ERR_add_error_vdata(int num, va_list arg);
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_put_func_err() is similar except that the B<func> is a string naming
41 a function external to OpenSSL, usually provided by the platform on which
42 OpenSSL and the application is running.
43
44 ERR_add_error_data() associates the concatenation of its B<num> string
45 arguments with the error code added last.
46 ERR_add_error_vdata() is similar except the argument is a B<va_list>.
47 Multiple calls to these functions append to the current top of the error queue.
48
49 L<ERR_load_strings(3)> can be used to register
50 error strings so that the application can a generate human-readable
51 error messages for the error code.
52
53 =head2 Reporting errors
54
55 Each sub-library has a specific macro XXXerr() that is used to report
56 errors. Its first argument is a function code B<XXX_F_...>, the second
57 argument is a reason code B<XXX_R_...>. Function codes are derived
58 from the function names; reason codes consist of textual error
59 descriptions. For example, the function ssl3_read_bytes() reports a
60 "handshake failure" as follows:
61
62  SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE);
63
64 Function and reason codes should consist of upper case characters,
65 numbers and underscores only. The error file generation script translates
66 function codes into function names by looking in the header files
67 for an appropriate function name, if none is found it just uses
68 the capitalized form such as "SSL3_READ_BYTES" in the above example.
69
70 The trailing section of a reason code (after the "_R_") is translated
71 into lower case and underscores changed to spaces.
72
73 Although a library will normally report errors using its own specific
74 XXXerr macro, another library's macro can be used. This is normally
75 only done when a library wants to include ASN1 code which must use
76 the ASN1err() macro.
77
78
79 =head1 RETURN VALUES
80
81 ERR_raise(), ERR_put_error() and ERR_add_error_data()
82 return no values.
83
84 =head1 NOTES
85
86 ERR_raise() is implemented as a macro.
87
88 =head1 SEE ALSO
89
90 L<ERR_load_strings(3)>
91
92 =head1 COPYRIGHT
93
94 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
95
96 Licensed under the Apache License 2.0 (the "License").  You may not use
97 this file except in compliance with the License.  You can obtain a copy
98 in the file LICENSE in the source distribution or at
99 L<https://www.openssl.org/source/license.html>.
100
101 =cut