Botan 3.6.1
Crypto and TLS for C&
Botan::Exception Class Reference

#include <exceptn.h>

Inheritance diagram for Botan::Exception:
Botan::CommonCrypto_Error Botan::Compression_Error Botan::Decoding_Error Botan::Encoding_Error Botan::HTTP::HTTP_Error Botan::Internal_Error Botan::Invalid_Argument Botan::Invalid_Authentication_Tag Botan::Invalid_State Botan::Lookup_Error Botan::No_Filesystem_Access Botan::Not_Implemented Botan::PKCS11::PKCS11_Error Botan::SQL_Database::SQL_DB_Error Botan::Stream_IO_Error Botan::System_Error Botan::TLS::TLS_Exception Botan::TPM2::Error Botan::TPM_Error Botan_FFI::FFI_Error

Public Member Functions

virtual int error_code () const noexcept
 
virtual ErrorType error_type () const noexcept
 
 Exception (const char *prefix, std::string_view msg)
 
 Exception (std::string_view msg)
 
 Exception (std::string_view msg, const std::exception &e)
 
const char * what () const noexcept override
 

Detailed Description

Base class for all exceptions thrown by the library

Definition at line 83 of file exceptn.h.

Constructor & Destructor Documentation

◆ Exception() [1/3]

Botan::Exception::Exception ( std::string_view msg)
explicit

Avoid throwing base Exception, use a subclass

Definition at line 71 of file exceptn.cpp.

71: m_msg(msg) {}

◆ Exception() [2/3]

Botan::Exception::Exception ( const char * prefix,
std::string_view msg )

Avoid throwing base Exception, use a subclass

Definition at line 75 of file exceptn.cpp.

75: m_msg(fmt("{} {}", prefix, msg)) {}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

◆ Exception() [3/3]

Botan::Exception::Exception ( std::string_view msg,
const std::exception & e )

Avoid throwing base Exception, use a subclass

Definition at line 73 of file exceptn.cpp.

73: m_msg(fmt("{} failed with {}", msg, e.what())) {}

Member Function Documentation

◆ error_code()

virtual int Botan::Exception::error_code ( ) const
inlinevirtualnoexcept

Return an error code associated with this exception, or otherwise 0.

The domain of this error varies depending on the source, for example on POSIX systems it might be errno, while on a Windows system it might be the result of GetLastError or WSAGetLastError.

Reimplemented in Botan::CommonCrypto_Error, Botan::Compression_Error, Botan::PKCS11::PKCS11_ReturnError, Botan::SQL_Database::SQL_DB_Error, Botan::System_Error, Botan::TLS::TLS_Exception, Botan::TPM2::Error, and Botan_FFI::FFI_Error.

Definition at line 107 of file exceptn.h.

107{ return 0; }

◆ error_type()

◆ what()

const char * Botan::Exception::what ( ) const
inlineoverridenoexcept

Return a descriptive string which is hopefully comprehensible to a developer. It will likely not be useful for an end user.

The string has no particular format, and the content of exception messages may change from release to release. Thus the main use of this function is for logging or debugging.

Definition at line 93 of file exceptn.h.

93{ return m_msg.c_str(); }

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan_FFI::ffi_guard_thunk(), Botan::TLS::Callbacks::tls_ephemeral_key_agreement(), Botan::TLS::Callbacks::tls_kem_encapsulate(), and Botan::X509_Certificate::to_string().


The documentation for this class was generated from the following files: