ERR_put_error.pod 3.3 KB

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