More reformatting

This commit is contained in:
Phil Nash 2012-05-16 08:02:20 +01:00
parent c67a7eef2b
commit 6cd2ac7544
11 changed files with 125 additions and 351 deletions

View file

@ -1,82 +1,53 @@
/*
* catch_exception_translator_registry.hpp
* Catch
*
* Created by Phil on 20/04/2011.
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#ifndef TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_HPP_INCLUDED
#include "catch_interfaces_exception.h"
namespace Catch
{
class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry
{
///////////////////////////////////////////////////////////////////////
~ExceptionTranslatorRegistry
()
{
namespace Catch {
class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
~ExceptionTranslatorRegistry() {
deleteAll( m_translators );
}
///////////////////////////////////////////////////////////////////////
virtual void registerTranslator
(
IExceptionTranslator* translator
)
{
virtual void registerTranslator( IExceptionTranslator* translator ) {
m_translators.push_back( translator );
}
///////////////////////////////////////////////////////////////////////
virtual std::string translateActiveException
()
const
{
try
{
virtual std::string translateActiveException() const {
try {
throw;
}
catch( std::exception& ex )
{
catch( std::exception& ex ) {
return ex.what();
}
catch( std::string& msg )
{
catch( std::string& msg ) {
return msg;
}
catch( const char* msg )
{
catch( const char* msg ) {
return msg;
}
catch(...)
{
catch(...) {
return tryTranslators( m_translators.begin() );
}
}
///////////////////////////////////////////////////////////////////////
std::string tryTranslators
(
std::vector<IExceptionTranslator*>::const_iterator it
)
const
{
std::string tryTranslators( std::vector<IExceptionTranslator*>::const_iterator it ) const {
if( it == m_translators.end() )
return "Unknown exception";
try
{
try {
return (*it)->translate();
}
catch(...)
{
catch(...) {
return tryTranslators( it+1 );
}
}