BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslfmt_formaterror

Detailed Description

Provide an exception type for format library errors.

Outline

Purpose

Provide an exception type for format library errors.

Classes

Canonical Header

bsl_format.h

Description

This component provides an implementation of the C++20 Standard Library's format_error , providing an exception type thrown in the event of an error in the formatting library.

Where the standard library <format> header is available, this is an alias to the std::format_error type.

This header is not intended to be included directly. Please include <bsl_format.h> to be able to use bsl::format_error.

Usage

In this section we show the intended use of this component.

Example: Indicate a Formatting Error

Typically a format_error exception would be thrown from the format or vformat functions. However, as this is at the very bottom of the dependency hierarchy the usage example cannot accurately reflect that case.

bool formatErrorCaught = false;
try {
throw bsl::format_error("Error message");
}
catch (const bsl::format_error &exc) {
formatErrorCaught = true;
assert(0 == strcmp(exc.what(), "Error message"));
}
assert(formatErrorCaught);