ERR_put_error.pod 4.5 KB

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