All Standard Exceptions
All Standard Exceptions
A compact scan page for the main standard C++ exception types, error-code types, and adjacent failure-reporting facilities.
All Standard Exceptions
A compact scan page for the main standard C++ exception types, error-code types, and adjacent failure-reporting facilities.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
Use this page as a fast scan. For grouped explanations, see Standard exceptions and errors.
std::exceptionstd::bad_exceptionstd::nested_exceptionstd::logic_errorstd::invalid_argumentstd::domain_errorstd::length_errorstd::out_of_rangestd::runtime_errorstd::range_errorstd::overflow_errorstd::underflow_errorstd::bad_allocstd::bad_array_new_lengthstd::bad_caststd::bad_typeidstd::bad_function_callstd::bad_optional_accessstd::bad_variant_accessstd::bad_any_caststd::bad_expected_access<E>std::ios_base::failurestd::filesystem::filesystem_errorstd::system_errorstd::error_codestd::error_conditionstd::error_categorystd::errcstd::exception_ptrstd::current_exceptionstd::rethrow_exceptionstd::make_exception_ptrerrnoperrorstrerrorstd::error_code when callers are expected to branch locally without throwing.std::expected<T, E> when failure is part of the ordinary API contract.#include <optional>
#include <stdexcept>
int require_count(std::optional<int> count) {
if (!count) {
throw std::invalid_argument{"count was missing"};
}
if (*count < 0) {
throw std::out_of_range{"count must be non-negative"};
}
return *count;
}
The useful habit is choosing the exception family by contract. Invalid caller input often maps to invalid_argument; broken bounds or indexing often map to out_of_range; system or environment failures often land in runtime_error or more specific derived types.
bad_optional_access or bad_variant_access when the standard type itself defines the misuse#include <optional>
#include <stdexcept>
int require_value(std::optional<int> value) {
if (!value) {
throw std::invalid_argument{"missing value"};
}
return *value;
}
int main() {
return require_value(42);
}