// ---------------------------------------------------------------------- // // ZMxel.cc - a ZMexception class interfacing to an ErrorLog // // ---------------------------------------------------------------------- #include "ErrLogEx/ZMxel.h" #include "ErrLogEx/ZMexErrorLog.h" #include "ErrorLogger/ErrorLog.h" // ---------------------------------------------------------------------- ZM_BEGIN_NAMESPACE( zmex ) /* namespace zmex { */ ZM_USING_NAMESPACE( zmel ) // ---------------------------------------------------------------------- // --- define class-wide default information: // ZMexClassInfo ZMxel::_classInfo( "ZMxel" , "Exceptions/ErrorLogger" , ZMexFATAL , ZMhandler() // STUB: need to specialize? , ZMlogger() // STUB: need to specialize? ); // ---------------------------------------------------------------------- // --- birth: // ZMxel::ZMxel( ErrorObj & errobj ) : ZMexception( /*mesg */ errobj.fullText() , /*howBad */ mapSeverity( errobj.xid().severity )// ZMexSEVERITYenumLAST , /*count */ ZMexception::_classInfo.nextCount() ) , myErrorObject( errobj ) { ; } // --- clone: // ZM_COVARIANT_TYPE(ZMexception,ZMxel) * ZMxel::clone() const { return new ZMxel( *this ); } // --- accessor: // ErrorObj & ZMxel::errorObject() const { return myErrorObject; } // --- class-wide info accessor: // ZMexClassInfo & ZMxel::classInfo() const { return ZMxel::_classInfo; } // --- request exception handling: // ZMexAction ZMxel::handleMe() const { // DEBUG cerr << "ZMxel::handleMe()" << endl; ZMexAction result( ZMxel::classInfo().getHandler().takeCareOf( *this ) ); return result == ZMexHANDLEVIAPARENT ? ZMexception::handleMe() : result ; } // handleMe() // --- request exception logging: // ZMexLogResult ZMxel::logMe() const { // DEBUG cerr << "ZMxel::logMe()" << endl; ZMexLogResult result( ZMxel::classInfo().getLogger().emit( *this ) ); return result == ZMexLOGVIAPARENT ? ZMexception::logMe() : result ; } // logMe() // --- hierarchy inquiry: // bool ZMxel::isDerivedFrom( const std::string aName , const std::string aFacility ) const { return aName == name() && aFacility == facility() ? true : ZMexception::isDerivedFrom( aName, aFacility ) ; } // isDerivedFrom() // --- map an ErrorLogger severity into an Exceptions severity: // ZMexSeverity ZMxel::mapSeverity( ELseverityLevel sev ) { return sev <= ELsuccess ? ZMexNORMAL : sev <= ELinfo ? ZMexINFO : sev <= ELwarning2 ? ZMexWARNING : sev <= ELnextEvent ? ZMexERROR : sev <= ELsevere2 ? ZMexSEVERE : sev <= ELfatal ? ZMexFATAL : sev <= ELhighestSeverity ? ZMexPROBLEM : ZMexSEVERITYenumLAST ; } // mapSeverity() // ---------------------------------------------------------------------- ZM_END_NAMESPACE( zmex ) /* } // namespace zmex */