You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using CATCH_TRANSLATE_EXCEPTION is convenient, but sometimes we want to test the concrete type and message. Using *_THROWS_MATCHES does not use the function provided by CATCH_TRANSLATE_EXCEPTION and just uses std::exception::what() (as documented). The output of what() prefixes the output of describe() without quotes or other annotation making the error harder to read and understand.
It may be that this is intentional and thus neither a bug nor a wanted feature. If so then I wonder if there is some way to customize the generated error messages that I may have missed in the docs.
Additional context
We're using version 3.6.0 here, but I will test 3.7.0 although I don't see any relevant changes.
The following program produces the output below it. I tried my best to make it as simple but complete as possible. It defines two exceptions, one of which does not inherit from std::exception, along with three matchers: one old matcher for each type and new generic matcher for both.
It turns out that both std::ostream& operator << ( std::ostream& os, Error const& value ) and Catch::StringMaker<Error> as mentioned in tostring.md work just fine for my purposes 😄 I think this could made a little clearer in the documentation, if it is indeed intentional that string matchers use the configured exception translators while other matchers do not, but I don't have an immediate suggestion as to how.
Description
Using
CATCH_TRANSLATE_EXCEPTION
is convenient, but sometimes we want to test the concrete type and message. Using*_THROWS_MATCHES
does not use the function provided byCATCH_TRANSLATE_EXCEPTION
and just usesstd::exception::what()
(as documented). The output ofwhat()
prefixes the output ofdescribe()
without quotes or other annotation making the error harder to read and understand.It may be that this is intentional and thus neither a bug nor a wanted feature. If so then I wonder if there is some way to customize the generated error messages that I may have missed in the docs.
Additional context
We're using version 3.6.0 here, but I will test 3.7.0 although I don't see any relevant changes.
The following program produces the output below it. I tried my best to make it as simple but complete as possible. It defines two exceptions, one of which does not inherit from
std::exception
, along with three matchers: one old matcher for each type and new generic matcher for both.The following is the output of the above program. Note the double space when using
MessageMatcher
(bug?).The text was updated successfully, but these errors were encountered: