---
name: "std::exception"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::exception/3cxx"
---

# std::exception(3cxx)

Base class for all library exceptions.

## NAME

std::exception - Base class for all library exceptions.

## SYNOPSIS

`#include <exception>`

Inherited by \_\_gnu\_cxx::\_\_concurrence\_broadcast\_error, \_\_gnu\_cxx::\_\_concurrence\_lock\_error, \_\_gnu\_cxx::\_\_concurrence\_unlock\_error, \_\_gnu\_cxx::\_\_concurrence\_wait\_error, **\_\_gnu\_cxx::forced\_error**, **std::bad\_alloc**, **std::bad\_cast**, **std::bad\_exception**, **std::bad\_function\_call**, **std::bad\_optional\_access**, **std::bad\_typeid**, std::bad\_variant\_access, **std::bad\_weak\_ptr**, **std::ios\_base::failure**, **std::logic\_error**, and **std::runtime\_error**.

### Public Member Functions

**exception** (const **exception** &)=**default**\
 **exception** (**exception** &&)=**default**\
 **exception** & **operator=** (const **exception** &)=**default**\
 **exception** & **operator=** (**exception** &&)=**default**\
 **virtual** const char \* **what** () const noexcept\

## Detailed Description

Base class for all library exceptions.

This is the base class for all exceptions thrown by the standard library, and by certain language expressions. You are free to derive your own exception classes, or use a different hierarchy, or to throw non-class data (e.g., fundamental types).

## Member Function Documentation

### virtual const char \* std::exception::what () const` [virtual]`, ` [noexcept]`

Returns a C-style character string describing the general cause of the current error. \

Reimplemented in **std::ios\_base::failure**, **std::bad\_alloc**, **std::bad\_any\_cast**, **std::filesystem::filesystem\_error**, **std::bad\_weak\_ptr**, **std::bad\_function\_call**, **std::experimental::fundamentals\_v1::bad\_any\_cast**, **std::experimental::filesystem::v1::filesystem\_error**, **std::future\_error**, **std::logic\_error**, **std::runtime\_error**, **std::bad\_exception**, **std::bad\_cast**, **std::bad\_typeid**, and **std::bad\_optional\_access**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
