defaultprotector.cpp
来自「c++ 实现的矩阵运算库」· C++ 代码 · 共 70 行
CPP
70 行
#include <cppunit/Exception.h>#include <cppunit/extensions/TypeInfoHelper.h>#include "DefaultProtector.h"#define MATRIX_UNIT_TESTING#ifdef MATRIX_UNIT_TESTING#include "../../../Matrix.h"#endifCPPUNIT_NS_BEGINbool DefaultProtector::protect( const Functor &functor, const ProtectorContext &context ){ try { return functor(); } catch ( Exception &failure ) { reportFailure( context, failure ); } catch ( std::exception &e ) { std::string shortDescription( "uncaught exception of type " );#if CPPUNIT_USE_TYPEINFO_NAME shortDescription += TypeInfoHelper::getClassName( typeid(e) );#else shortDescription += "std::exception (or derived).";#endif Message message( shortDescription, e.what() ); reportError( context, message ); }#ifdef MATRIX_UNIT_TESTING //// // added by GDM#ifndef _MATRIX_NO_EXCEPTION#ifdef _MATRIX_NO_NAMESPACE catch ( MatrixException &matrix_exception ) { reportError( context, Message( matrix_exception.GetExceptionMessage() ) ); }#else catch ( Zenautics::MatrixException &matrix_exception ) { reportError( context, Message( matrix_exception.GetExceptionMessage() ) ); }#endif#endif // ////#endif catch ( ... ) { reportError( context, Message( "uncaught exception of unknown type") ); } return false;}CPPUNIT_NS_END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?