ERR_NEW(3SSL)

✨ ERR_new β€” the error-recording building blocks (yes bestie, we're going behind the scenes) ✨

okay so this one is from the OpenSSL manual, section 3SSL, and it's all about the lil' LEGO bricks 🧱 that build error reporting. Let's get into it. πŸ’…


🌸 NAME 🌸

ERR_new, ERR_set_debug, ERR_set_error, ERR_vset_error β€” error recording building blocks. That's it, that's the whole vibe check. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <openssl/err.h>

void ERR_new(void);
void ERR_set_debug(const char *file, int line, const char *func);
void ERR_set_error(int lib, int reason, const char *fmt, ...);
void ERR_vset_error(int lib, int reason, const char *fmt, va_list args);

πŸ’– DESCRIPTION πŸ’–

So like, the tea β˜• is that these functions are generally not used directly β€” you'd normally meet them through macros like ERR_raise(3). But bestie, if you wanna cook up your own macros? They're literally right there for you. Slay. πŸ‘‘

ERR_new() β€” allocates a new slot in the thread's error queue. It's giving "make room, someone's about to spill something." ✨

ERR_set_debug() β€” sets the debug information for the current error in the thread's error queue. The values you can hand it are:

  • the filename file,
  • the line number in the file line,
  • and the name of the function func where the error happened.
⚠️ no cap on this one: the names must be constant. This function only saves away the pointers, it does not copy the strings. So if your string is out here living a short life on the stack, that pointer is gonna be pointing at nothing and it's gonna be awkward. 😭

ERR_set_error() β€” sets the error information, which is the library number lib and the reason code reason, plus some additional data as a format string fmt and an arbitrary number of arguments. That additional data gets processed with BIO_snprintf(3) to form the additional data string, which is then allocated and stored in the error record. Iconic pipeline behavior. 🫢

ERR_vset_error() β€” same energy as ERR_set_error(), except it takes a va_list argument instead of a variable number of arguments. fr fr, that's the only difference. πŸ¦‹


🌈 RETURN VALUES 🌈

ERR_new, ERR_set_debug, ERR_set_error and ERR_vset_error do not return any values. Nothing. Nada. Void. They're all void, they said "not my job to report back." πŸ’€


πŸ’œ NOTES πŸ’œ

The library number is unique to each unit that records errors. OpenSSL has a number of preallocated ones for its own uses, but others may allocate their own library number dynamically with ERR_get_next_error_library(3). DIY queen behavior. πŸ‘‘

Reason codes are unique within each library, and may have an associated set of strings as a short description of the reason. For dynamically allocated library numbers, reason strings are recorded with ERR_load_strings(3). πŸŽ€

Provider authors, this part is for you: you're supplied with core versions of these functions β€” see provider-base(7). 🧚


🌟 SEE ALSO 🌟


Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page bestie 🫢 this was version 4.0.3, dated 2026-09-29, from the OpenSSL crew β€” stay hydrated, keep your pointers valid, and don't forget to check your error queue. πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from