checkError static method
Checks the OpenSSL error queue. If there are errors, throws an SslException. Should be called after a C function returns a failure code.
Implementation
static void checkError(OpenSslFfi lib,
{String? function, bool throwIfError = true}) {
// Get the most recent error
final code = lib.ERR_get_error();
if (code != 0) {
if (!throwIfError) return;
final buffer = calloc<Char>(256);
try {
lib.ERR_error_string(code, buffer);
final msg = buffer.cast<Utf8>().toDartString();
throw OpenSslException(msg, code, function);
} finally {
calloc.free(buffer);
}
}
}