exception translators considered even for types deriving from std::exception, now

- also added docs for exception translators
- updated approvals
This commit is contained in:
Phil Nash 2015-11-18 08:39:21 +00:00
parent ed6e9128a4
commit a49f088032
8 changed files with 101 additions and 28 deletions

View file

@ -106,22 +106,50 @@ private:
std::string m_msg;
};
class CustomStdException : public std::exception
{
public:
CustomStdException( const std::string& msg )
: m_msg( msg )
{}
std::string getMessage() const
{
return m_msg;
}
private:
std::string m_msg;
};
CATCH_TRANSLATE_EXCEPTION( CustomException& ex )
{
return ex.getMessage();
}
CATCH_TRANSLATE_EXCEPTION( CustomStdException& ex )
{
return ex.getMessage();
}
CATCH_TRANSLATE_EXCEPTION( double& ex )
{
return Catch::toString( ex );
}
TEST_CASE("Unexpected custom exceptions can be translated", "[.][failing]" )
TEST_CASE("Non-std exceptions can be translated", "[.][failing]" )
{
if( Catch::alwaysTrue() )
throw CustomException( "custom exception" );
}
TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing]" )
{
if( Catch::alwaysTrue() )
throw CustomException( "custom std exception" );
}
inline void throwCustom() {
if( Catch::alwaysTrue() )
throw CustomException( "custom exception - not std" );