Skip to content

Support width and alignment in std::exception formatter#4860

Open
s3yato wants to merge 1 commit into
fmtlib:mainfrom
s3yato:feature/exception-formatter-align
Open

Support width and alignment in std::exception formatter#4860
s3yato wants to merge 1 commit into
fmtlib:mainfrom
s3yato:feature/exception-formatter-align

Conversation

@s3yato

@s3yato s3yato commented Jul 20, 2026

Copy link
Copy Markdown

The formatter for std::exception (and std::exception_ptr) previously accepted only the optional 't' type-name specifier, so standard fill, align and width specifiers were rejected with "unknown format specifier". This made it impossible to pad or align exception messages, e.g. when laying them out in a log column.

Parse the standard fill/align/width specifiers (as the std::filesystem:: path formatter already does) and apply them when writing the message. Dynamic width ({:{}}) and the 'none'/'unknown exception' cases for exception_ptr are handled too. Existing behavior ({}, {:t}, nested exception unwinding) is unchanged.

@s3yato
s3yato requested a review from vitaut as a code owner July 20, 2026 14:26
The formatter for std::exception (and std::exception_ptr) previously
accepted only the optional 't' type-name specifier, so standard fill,
align and width specifiers were rejected with "unknown format
specifier". This made it impossible to pad or align exception messages,
e.g. when laying them out in a log column.

Parse the standard fill/align/width specifiers (as the std::filesystem::
path formatter already does) and apply them when writing the message.
Dynamic width ({:{}}) and the 'none'/'unknown exception' cases for
exception_ptr are handled too. Existing behavior ({}, {:t}, nested
exception unwinding) is unchanged.
@s3yato
s3yato force-pushed the feature/exception-formatter-align branch from da270bc to b059132 Compare July 20, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants