1.\" $OpenBSD: ERR_put_error.3,v 1.11 2024/08/29 20:23:21 tb Exp $ 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 3.\" 4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 5.\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in 16.\" the documentation and/or other materials provided with the 17.\" distribution. 18.\" 19.\" 3. All advertising materials mentioning features or use of this 20.\" software must display the following acknowledgment: 21.\" "This product includes software developed by the OpenSSL Project 22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 23.\" 24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 25.\" endorse or promote products derived from this software without 26.\" prior written permission. For written permission, please contact 27.\" openssl-core@openssl.org. 28.\" 29.\" 5. Products derived from this software may not be called "OpenSSL" 30.\" nor may "OpenSSL" appear in their names without prior written 31.\" permission of the OpenSSL Project. 32.\" 33.\" 6. Redistributions of any form whatsoever must retain the following 34.\" acknowledgment: 35.\" "This product includes software developed by the OpenSSL Project 36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 37.\" 38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" 51.Dd $Mdocdate: August 29 2024 $ 52.Dt ERR_PUT_ERROR 3 53.Os 54.Sh NAME 55.Nm ERR_put_error 56.Nd record an OpenSSL error 57.Sh SYNOPSIS 58.In openssl/err.h 59.Ft void 60.Fo ERR_put_error 61.Fa "int lib" 62.Fa "int func" 63.Fa "int reason" 64.Fa "const char *file" 65.Fa "int line" 66.Fc 67.Sh DESCRIPTION 68.Fn ERR_put_error 69adds an error code to the thread's error queue. 70It signals that the error of reason code 71.Fa reason 72occurred in function 73.Fa func 74of library 75.Fa lib , 76in line number 77.Fa line 78of 79.Fa file . 80This function is usually called by a macro. 81.Pp 82.Xr ERR_load_strings 3 83can be used to register error strings so that the application can 84generate human-readable error messages for the error code. 85.Pp 86Each sub-library has a specific macro 87.Fn XXXerr f r 88that is used to report errors. 89Its first argument is a function code 90.Dv XXX_F_* ; 91the second argument is a reason code 92.Dv XXX_R_* . 93Function codes are derived from the function names 94whereas reason codes consist of textual error descriptions. 95For example, the function 96.Fn ssl23_read 97reports a "handshake failure" as follows: 98.Pp 99.Dl SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE); 100.Pp 101Function and reason codes should consist of upper case characters, 102numbers and underscores only. 103The error file generation script translates function codes into function 104names by looking in the header files for an appropriate function name. 105If none is found, it just uses the capitalized form such as "SSL23_READ" 106in the above example. 107.Pp 108The trailing section of a reason code (after the "_R_") is translated 109into lower case and underscores changed to spaces. 110.Pp 111Although a library will normally report errors using its own specific 112.Fn XXXerr 113macro, another library's macro can be used. 114This is normally only done when a library wants to include ASN.1 code 115which must use the 116.Fn ASN1err 117macro. 118.Sh SEE ALSO 119.Xr ERR 3 , 120.Xr ERR_asprintf_error_data 3 , 121.Xr ERR_load_strings 3 122.Sh HISTORY 123.Fn ERR_put_error 124first appeared in SSLeay 0.4.4 and has been available since 125.Ox 2.4 . 126