Class ExceptionTranslatorRegistrar

Synopsis

#include <include/internal/catch_interfaces_exception.h>

class ExceptionTranslatorRegistrar

Description

No description yet.

Methods

ExceptionTranslatorRegistrar

Source

Lines 39-74 in include/internal/catch_interfaces_exception.h.

class ExceptionTranslatorRegistrar {
    template<typename T>
    class ExceptionTranslator : public IExceptionTranslator {
    public:
        ExceptionTranslator( std::string(*translateFunction)( T& ) )
        : m_translateFunction( translateFunction )
        {}
        std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override {
defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
            return "";
e
            try {
                if( it == itEnd )
                    std::rethrow_exception(std::current_exception());
                else
                    return (*it)->translate( it+1, itEnd );
            }
            catch( T& ex ) {
                return m_translateFunction( ex );
            }
if
        }
    protected:
        std::string(*m_translateFunction)( T& );
    };
public:
    template<typename T>
    ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
        getMutableRegistryHub().registerTranslator
            ( new ExceptionTranslator<T>( translateFunction ) );
    }
};





Add Discussion as Guest

Log in