fmt
fmt copied to clipboard
Support std::exception
Exceptions are not supported, as they are not formattable:
int main() try {
std::vector <int> vec;
vec.at(42);
} catch(const std::out_of_range& ex){
fmt::print("{}", ex);
}
https://godbolt.org/z/ejTMEYr3b
In practice, the expected/desired behavior would be to print the error message. Ie if they would behave as-if
int main() try {
std::vector<int> vec;
vec.at(42);
} catch(const std::out_of_range& ex){
fmt::print("{}", ex.what());
}
This can be accomplished by defining a custom formatter for std::exception
, but as fmt
already provides formatters for many/most types from the standard library, support for std::exception should be part of it.
Sure, a PR to add a formatter specialization is welcome.