Standard Exceptions and Errors

Standard Exceptions and Errors

The main C++ exception families, error-code facilities, and adjacent C error-reporting mechanisms.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

Standard Exceptions and Errors

C++ exception hierarchy overview

At the broadest level, most standard exceptions derive from std::exception.

Core base classes

Logic errors

Types from <stdexcept> that usually represent programming mistakes or invalid use:

Runtime errors

Types from <stdexcept> that usually represent failures discovered during execution:

Memory and casting failures

Filesystem and system error facilities

Exception pointer facilities

C-style adjacent error reporting

When working closer to C APIs or POSIX-style interfaces, you will also see:

Practical guidance

Example in practice

int main() {
    // Pick one facility from this reference page.
    // Write the smallest program that exercises its main precondition,
    // complexity rule, or lifetime constraint before scaling up.
    return 0;
}