![]() |
|
|
Generated: 8 Jan 2009 |
00001 // $Id: GslErrorException.cpp,v 1.2 2006/01/10 20:00:05 hmd Exp $ 00002 // ============================================================================ 00003 // ============================================================================ 00004 // Include files 00005 // from Gaudi 00006 #include "GaudiKernel/ToolFactory.h" 00007 #include "GaudiKernel/MsgStream.h" 00008 #include "GaudiKernel/GaudiException.h" 00009 // STD & STL 00010 #include <algorithm> 00011 // local 00012 #include "GslErrorException.h" 00013 00014 // ============================================================================ 00022 // ============================================================================ 00023 00024 // ============================================================================ 00031 // ============================================================================ 00032 DECLARE_TOOL_FACTORY(GslErrorException) 00033 // ============================================================================ 00034 00035 // ============================================================================ 00041 // ============================================================================ 00042 GslErrorException::GslErrorException 00043 ( const std::string& type , 00044 const std::string& name , 00045 const IInterface* parent ) 00046 : AlgTool ( type, name , parent ) 00047 , m_ignore () 00048 { 00049 declareInterface<IGslErrorHandler> (this); 00050 declareProperty ( "IgnoreCodes" , m_ignore ); 00051 }; 00052 // ============================================================================ 00053 00054 // ============================================================================ 00056 // ============================================================================ 00057 GslErrorException::~GslErrorException(){}; 00058 // ============================================================================ 00059 00060 // ============================================================================ 00067 // ============================================================================ 00068 StatusCode GslErrorException::handle 00069 ( const GslError& error ) const 00070 { 00071 StatusCode sc = StatusCode::SUCCESS ; 00072 // code to be ignored? 00073 if( m_ignore.end() != std::find( m_ignore.begin () , 00074 m_ignore.end () , 00075 error.code ) ) { return sc ; } 00076 // 00077 std::string message( " GSL ErrorCode=" ); 00078 static char s_aux[512]; 00079 message += 00080 std::string( s_aux , s_aux + sprintf( s_aux , "%d" , error.code ) ); 00081 message += ": '" ; 00082 message += error.reason ; 00083 message += "' in the file '" ; 00084 message += error.file ; 00085 message += "' at the line " ; 00086 message += 00087 std::string( s_aux , s_aux + sprintf( s_aux , "%d" , error.line ) ); 00088 message += "'" ; 00089 throw GaudiException( message , "*GLS Error*" , StatusCode::FAILURE ); 00091 return StatusCode::SUCCESS ; 00092 }; 00093 // ============================================================================ 00094 00095 00096 // ============================================================================ 00097 // The END 00098 // ============================================================================