mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 23:36:11 +01:00
Removed need for Error class to capture stream inserted strings into exceptions
This commit is contained in:
parent
bada67bb72
commit
8c757cc542
@ -116,29 +116,16 @@ namespace Catch {
|
|||||||
T const& operator + ( T const& value, StreamEndStop ) {
|
T const& operator + ( T const& value, StreamEndStop ) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ExceptionT = std::domain_error>
|
|
||||||
class Error {
|
|
||||||
std::ostringstream m_oss;
|
|
||||||
|
|
||||||
public:
|
|
||||||
template<typename T>
|
|
||||||
auto operator <<( T const& value ) -> Error& {
|
|
||||||
m_oss << value;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[noreturn]]
|
|
||||||
void raise() {
|
|
||||||
throw ExceptionT( m_oss.str() );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
|
#define CATCH_INTERNAL_LINEINFO \
|
||||||
#define CATCH_INTERNAL_ERROR( msg ) do{ ( ::Catch::Error<std::logic_error>() << CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg ).raise(); } while(false)
|
::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
|
||||||
#define CATCH_ERROR( msg ) ( ::Catch::Error<>() << msg ).raise()
|
#define CATCH_INTERNAL_ERROR( msg ) \
|
||||||
#define CATCH_ENFORCE( condition, msg ) do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
|
throw std::logic_error( ( std::ostringstream() << CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg ).str() )
|
||||||
|
#define CATCH_ERROR( msg ) \
|
||||||
|
throw std::domain_error( ( std::ostringstream() << msg ).str() )
|
||||||
|
#define CATCH_ENFORCE( condition, msg ) \
|
||||||
|
do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user