mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Add stringification support to std::exception and deriving classes
This support is based on overriden `std::exception::what` method, so if an exception does not do so meaningfully, the message is still pointless. This is only used as a fallback, both `StringMaker` specialization and `operator<<` overload have priority..
This commit is contained in:
		| @@ -62,7 +62,9 @@ namespace Catch { | ||||
|         std::string convertUnknownEnumToString( E e ); | ||||
|  | ||||
|         template<typename T> | ||||
|         typename std::enable_if<!std::is_enum<T>::value, std::string>::type convertUnstreamable( T const& value ) { | ||||
|         typename std::enable_if< | ||||
|             !std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value, | ||||
|         std::string>::type convertUnstreamable( T const& value ) { | ||||
| #if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER) | ||||
|             (void)value; | ||||
|             return Detail::unprintableString; | ||||
| @@ -71,11 +73,20 @@ namespace Catch { | ||||
| #endif | ||||
|         } | ||||
|         template<typename T> | ||||
|         typename std::enable_if<std::is_enum<T>::value, std::string>::type convertUnstreamable( T const& value ) { | ||||
|             return convertUnknownEnumToString( value ); | ||||
|         typename std::enable_if< | ||||
|             !std::is_enum<T>::value && std::is_base_of<std::exception, T>::value, | ||||
|          std::string>::type convertUnstreamable(T const& ex) { | ||||
|             return ex.what(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         template<typename T> | ||||
|         typename std::enable_if< | ||||
|             std::is_enum<T>::value | ||||
|         , std::string>::type convertUnstreamable( T const& value ) { | ||||
|             return convertUnknownEnumToString( value ); | ||||
|         } | ||||
|  | ||||
| #if defined(_MANAGED) | ||||
|         //! Convert a CLR string to a utf8 std::string | ||||
|         template<typename T> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský