Standard library header <exception> - cppreference.com

From cppreference.com

This header is part of the

error handling

library.

Types

exception

base class for exceptions thrown by the standard library components
(class)

[edit]

nested_exception

(C++11)

a mixin type to capture and store current exceptions
(class)

[edit]

bad_exception

exception thrown when

std::current_exception

fails to copy the exception object
(class)

[edit]

unexpected_handler

(deprecated in C++11)(removed in C++17)

the type of the function called by

std::unexpected

(typedef)

[edit]

terminate_handler

the type of the function called by

std::terminate

(typedef)

[edit]

exception_ptr

(C++11)

shared pointer type for handling exception objects
(typedef)

[edit]

Functions

unexpected

(deprecated in C++11)(removed in C++17)

function called when dynamic exception specification is violated
(function)

[edit]

uncaught_exceptionuncaught_exceptions

(removed in C++20*)(C++17)

checks if exception handling is currently in progress
(function)

[edit]

make_exception_ptr

(C++11)

creates an

std::exception_ptr

from an exception object
(function template)

[edit]

current_exception

(C++11)

captures the current exception in a

std::exception_ptr

(function)

[edit]

rethrow_exception

(C++11)

throws the exception from an

std::exception_ptr

(function)

[edit]

throw_with_nested

(C++11)

throws its argument with

std::nested_exception

mixed in
(function template)

[edit]

rethrow_if_nested

(C++11)

throws the exception from a

std::nested_exception

(function template)

[edit]

terminate

function called when exception handling fails
(function)

[edit]

get_terminate

(C++11)

obtains the current terminate_handler
(function)

[edit]

set_terminate

changes the function to be called by

std::terminate

(function)

[edit]

get_unexpected

(deprecated in C++11)(removed in C++17)

obtains the current unexpected_handler
(function)

[edit]

set_unexpected

(deprecated in C++11)(removed in C++17)

changes the function to be called by

std::unexpected

(function)

[edit]

Synopsis

namespacestd{classexception;classbad_exception;classnested_exception;usingterminate_handler=void(*)();terminate_handlerget_terminate()noexcept;terminate_handlerset_terminate(terminate_handlerf)noexcept;[[noreturn]]voidterminate()noexcept;intuncaught_exceptions()noexcept;usingexception_ptr=/* unspecified */;exception_ptrcurrent_exception()noexcept;[[noreturn]]voidrethrow_exception(exception_ptrp);template<classE>exception_ptrmake_exception_ptr(Ee)noexcept;template<classT>[[noreturn]]voidthrow_with_nested(T&&t);template<classE>voidrethrow_if_nested(constE&e);}Class

std::exception

namespacestd{classexception{public:exception()noexcept;exception(constexception&)noexcept;exception&operator=(constexception&)noexcept;virtual~exception();virtualconstchar*what()constnoexcept;};}Class

std::bad_exception

namespacestd{classbad_exception:publicexception{public:// see [exception] for the specification of the special member functionsconstchar*what()constnoexceptoverride;};}Class

std::nested_exception

namespacestd{classnested_exception{public:nested_exception()noexcept;nested_exception(constnested_exception&)noexcept=default;nested_exception&operator=(constnested_exception&)noexcept=default;virtual~nested_exception()=default;// access functions[[noreturn]]voidrethrow_nested()const;exception_ptrnested_ptr()constnoexcept;};template<classT>[[noreturn]]voidthrow_with_nested(T&&t);template<classE>voidrethrow_if_nested(constE&e);}See also

Error handling