mirror of
https://github.com/catchorg/Catch2.git
synced 2025-06-06 23:40:55 +00:00
exception translators considered even for types deriving from std::exception, now
- also added docs for exception translators - updated approvals
This commit is contained in:
parent
ed6e9128a4
commit
a49f088032
8 changed files with 101 additions and 28 deletions
|
@ -9,15 +9,20 @@
|
|||
#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "catch_interfaces_registry_hub.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
typedef std::string(*exceptionTranslateFunction)();
|
||||
|
||||
struct IExceptionTranslator;
|
||||
typedef std::vector<const IExceptionTranslator*> ExceptionTranslators;
|
||||
|
||||
struct IExceptionTranslator {
|
||||
virtual ~IExceptionTranslator();
|
||||
virtual std::string translate() const = 0;
|
||||
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
|
||||
};
|
||||
|
||||
struct IExceptionTranslatorRegistry {
|
||||
|
@ -35,9 +40,12 @@ namespace Catch {
|
|||
: m_translateFunction( translateFunction )
|
||||
{}
|
||||
|
||||
virtual std::string translate() const {
|
||||
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE {
|
||||
try {
|
||||
throw;
|
||||
if( it == itEnd )
|
||||
throw;
|
||||
else
|
||||
return (*it)->translate( it+1, itEnd );
|
||||
}
|
||||
catch( T& ex ) {
|
||||
return m_translateFunction( ex );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue