| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends

# ExceptionSvc Class Reference

Simple implementation of IExceptionSvc abstract interface. More...

`#include <ExceptionSvc.h>`

Inheritance diagram for ExceptionSvc:
[legend]
Collaboration diagram for ExceptionSvc:
[legend]

List of all members.

## Public Member Functions
virtual StatusCode | handle (const INamedInterface &o, const GaudiException &e) const
| Handle caught GaudiExceptions.
virtual StatusCode | handle (const INamedInterface &o, const std::exception &e) const
| Handle caught std::exceptions.
virtual StatusCode | handle (const INamedInterface &o) const
| Handle caught (unknown)exceptions.
virtual StatusCode | handleErr (const INamedInterface &o, const StatusCode &s) const
| Handle errors.
virtual StatusCode | initialize ()
| initialize the service
virtual StatusCode | finalize ()
| finalize the service
| ExceptionSvc (const std::string &name, ISvcLocator *svc)
| standard constructor
virtual | ~ExceptionSvc ()
| Destructor.
## Private Types
enum | Policy { ALL, NONE }
enum | ReturnState { SUCCESS, FAILURE, RECOVERABLE, RETHROW, DEFAULT }
## Private Member Functions
| ExceptionSvc ()
| no default constructor
| ExceptionSvc (const ExceptionSvc &)
| no copy constructor
ExceptionSvc & | operator= (const ExceptionSvc &)
| no assignement
## Private Attributes
Policy | m_mode_exc
Policy | m_mode_err
StringProperty | m_mode_exc_s
StringProperty | m_mode_err_s
std::map< std::string, ReturnState > | m_retCodesExc
std::map< std::string, ReturnState > | m_retCodesErr
MsgStream | m_log
## Friends
class | SvcFactory< ExceptionSvc >

## Detailed Description

Simple implementation of IExceptionSvc abstract interface.

Author:
  (1) ATLAS collaboration
  (2) modified by Vanya BELYAEV ibelyaev@physics.syr.edu

Date:
  2007-03-08

Definition at line 24 of file ExceptionSvc.h.

## Member Enumeration Documentation

enum ExceptionSvc::Policy`[private]`

Enumerator:

  ALL |
  NONE |

Definition at line 66 of file ExceptionSvc.h.

    { ALL, NONE };

enum ExceptionSvc::ReturnState`[private]`

Enumerator:

  SUCCESS | Normal successful completion.
  FAILURE |
  RECOVERABLE |
  RETHROW |
  DEFAULT |

Definition at line 67 of file ExceptionSvc.h.

    { SUCCESS, FAILURE, RECOVERABLE, RETHROW, DEFAULT };

## Constructor & Destructor Documentation

ExceptionSvc::ExceptionSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

standard constructor

Parameters:

  name | service instance name
  pSvc | pointer to Service Locator

Definition at line 39 of file ExceptionSvc.cpp.

      : base_class( name, svc )
      , m_mode_exc ( ALL ), m_mode_err( NONE )
      , m_log(msgSvc(), name )
    {
      // for exceptions
      declareProperty( "Catch"      , m_mode_exc_s="ALL" ) ;

      // for return codes
      declareProperty( "Errors"     , m_mode_err_s="NONE" ) ;
    }

ExceptionSvc::~ExceptionSvc | ( | ) | `[virtual]`

Destructor.

Definition at line 53 of file ExceptionSvc.cpp.

                                {

    }

ExceptionSvc::ExceptionSvc | ( | ) | `[private]`

no default constructor

ExceptionSvc::ExceptionSvc | ( | const ExceptionSvc & | ) | `[private]`

no copy constructor

## Member Function Documentation

StatusCode ExceptionSvc::finalize | ( | void | ) | `[virtual]`

finalize the service

Reimplemented from Service.

Definition at line 204 of file ExceptionSvc.cpp.

                           {
      StatusCode status = Service::finalize();

      return status;
    }

StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o,
|  | const std::exception & | e
| ) |  | const`[virtual]`

Handle caught std::exceptions.

Handle caught exceptions

Implements IExceptionSvc.

Definition at line 294 of file ExceptionSvc.cpp.

    {
      m_log << MSG::DEBUG << "Handling std:except for " << alg.name() << endmsg;

      // is this Alg special?
      if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) {
        ReturnState iret = m_retCodesExc.find(alg.name())->second;

        switch ( iret ) {
        case DEFAULT:
          // there is no default
          return StatusCode::FAILURE;
        case SUCCESS:
          return StatusCode::SUCCESS;
        case FAILURE:
          return StatusCode::FAILURE;
        case RECOVERABLE:
          return StatusCode::RECOVERABLE;
        case RETHROW:
          throw ( exc );
        }

      } else {

        if (m_mode_exc == ALL) {
          throw (exc);
        } else {
          assert (m_mode_exc == NONE);
          return StatusCode::FAILURE;
        }
      }

      return StatusCode::FAILURE;

    }

StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o ) | const`[virtual]`

Handle caught (unknown)exceptions.

Handle caught exceptions

Implements IExceptionSvc.

Definition at line 256 of file ExceptionSvc.cpp.

    {
      m_log << MSG::DEBUG << "Handling unknown exception for " << alg.name() << endmsg;

      // is this Alg special?
      if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) {
        ReturnState iret = m_retCodesExc.find(alg.name())->second;

        switch ( iret ) {
        case DEFAULT:
          // there is no default
          return StatusCode::FAILURE;
        case SUCCESS:
          return StatusCode::SUCCESS;
        case FAILURE:
          return StatusCode::FAILURE;
        case RECOVERABLE:
          return StatusCode::RECOVERABLE;
        case RETHROW:
          throw;
        }

      } else {

        if (m_mode_exc == ALL) {
          throw;
        } else {
          assert (m_mode_exc == NONE);
          return StatusCode::FAILURE;
        }
      }

      return StatusCode::FAILURE;

    }

StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o,
|  | const GaudiException & | e
| ) |  | const`[virtual]`

Handle caught GaudiExceptions.

Handle caught exceptions

Implements IExceptionSvc.

Definition at line 333 of file ExceptionSvc.cpp.

    {

      m_log << MSG::DEBUG << "Handling GaudiExcept for " << alg.name() << endmsg;

      // is this Alg special?
      if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) {
        ReturnState iret = m_retCodesExc.find(alg.name())->second;

        switch ( iret ) {
        case DEFAULT:
          return exc.code();
        case SUCCESS:
          return StatusCode::SUCCESS;
        case FAILURE:
          return StatusCode::FAILURE;
        case RECOVERABLE:
          return StatusCode::RECOVERABLE;
        case RETHROW:
          throw ( exc );
        }

      } else {

        if (m_mode_exc == ALL) {
          throw (exc);
        } else {
          assert (m_mode_exc == NONE);
          return StatusCode::FAILURE;
        }
      }

      return StatusCode::FAILURE;

    }

StatusCode ExceptionSvc::handleErr | ( | const INamedInterface & | o,
|  | const StatusCode & | s
| ) |  | const`[virtual]`

Handle errors.

Handle errors

Implements IExceptionSvc.

Definition at line 213 of file ExceptionSvc.cpp.

    {
      m_log << MSG::DEBUG << "Handling Error from " << alg.name() << endmsg;

      // is this Alg special?
      if (m_retCodesErr.find(alg.name()) != m_retCodesErr.end()) {
        ReturnState iret = m_retCodesErr.find(alg.name())->second;

        switch ( iret ) {
        case SUCCESS:
          return StatusCode::SUCCESS;
        case FAILURE:
          return StatusCode::FAILURE;
        case RECOVERABLE:
          return StatusCode::RECOVERABLE;
        case RETHROW:
          // should never get here
          break;
        case DEFAULT:
          // should never get here
          break;
        }

      } else {

        if (m_mode_err == ALL) {
          // turn it into a FAILURE
          return StatusCode::FAILURE;

        } else {
          assert (m_mode_err == NONE );
          // don't touch the return code
          return st;
        }
      }

      return StatusCode::FAILURE;

    }

StatusCode ExceptionSvc::initialize | ( | void | ) | `[virtual]`

initialize the service

Reimplemented from Service.

Definition at line 61 of file ExceptionSvc.cpp.

                             {
      StatusCode status = Service::initialize();
      m_log.setLevel( m_outputLevel.value() );

      if ( status.isFailure() )  { return status ; }                  // RETURN

      string key = m_mode_exc_s.value();

      string::size_type loc = key.find(" ");
      std::string mode;
      if (loc == std::string::npos) {
        mode = key;
      } else {
        mode = key.substr(0,loc);
      }

      toupper(mode);

      if (mode == "NONE") {
        m_mode_exc = NONE;
      } else if (mode == "ALL") {
        m_mode_exc = ALL;
      } else {
        m_log << MSG::ERROR << "Unknown mode for Exception handling: \"" << mode
            << "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg;
        m_state = Gaudi::StateMachine::OFFLINE;
        return StatusCode::FAILURE;
      }

      if (loc == string::npos) {
        key = "";
      } else {
        key = key.substr(loc+1,key.length());
      }

      Tokenizer tok(true);
      std::string val,VAL,TAG;

      tok.analyse( key, " ", "", "", "=", "", "");

      for ( Tokenizer::Items::iterator i = tok.items().begin();
            i != tok.items().end(); i++)    {
        const std::string& tag = (*i).tag();
        TAG = tag;

        val = (*i).value();
        VAL = val;
        toupper(VAL);

        if (VAL == "SUCCESS") {
          m_retCodesExc[TAG] = SUCCESS;
        } else if ( VAL == "FAILURE" ) {
          m_retCodesExc[TAG] = FAILURE;
        } else if ( VAL == "REVOVERABLE" ) {
          m_retCodesExc[TAG] = RECOVERABLE;
        } else if ( VAL == "RETHROW" ) {
          m_retCodesExc[TAG] = RETHROW;
        } else if ( VAL == "DEFAULT" ) {
          m_retCodesExc[TAG] = DEFAULT;
        } else {
          m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL
              << "\" for Algorithm " << TAG << std::endl
              << "   Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW"
              << endmsg;
          m_state = Gaudi::StateMachine::OFFLINE;
          return StatusCode::FAILURE;
        }

        m_log << MSG::DEBUG << "Will catch exceptions thrown by: " << TAG
            << " -> action: " << VAL << endmsg;

      }

      // now process errors

      key = m_mode_err_s.value();

      loc = key.find(" ");
      if (loc == std::string::npos) {
        mode = key;
      } else {
        mode = key.substr(0,loc);
      }

      toupper(mode);

      if (mode == "NONE") {
        m_mode_err = NONE;
      } else if (mode == "ALL") {
        m_mode_err = ALL;
      } else {
        m_log << MSG::ERROR << "Unknown mode for Error handling: \"" << mode
            << "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg;
        m_state = Gaudi::StateMachine::OFFLINE;
        return StatusCode::FAILURE;
      }

      if (loc == string::npos) {
        key = "";
      } else {
        key = key.substr(loc+1,key.length());
      }

      Tokenizer tok2(true);
      tok2.analyse( key, " ", "", "", "=", "", "");

      for ( Tokenizer::Items::iterator i = tok2.items().begin();
            i != tok2.items().end(); i++)    {
        const std::string& tag = (*i).tag();
        TAG = tag;

        val = (*i).value();
        VAL = val;
        toupper(VAL);

        if (VAL == "SUCCESS") {
          m_retCodesErr[TAG] = SUCCESS;
        } else if ( VAL == "FAILURE" ) {
          m_retCodesErr[TAG] = FAILURE;
        } else if ( VAL == "RECOVERABLE" ) {
          m_retCodesErr[TAG] = RECOVERABLE;
        } else {
          m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL
              << "\" for Algorithm " << TAG << std::endl
              << "   Must be one of: SUCCESS, FAILURE, RECOVERABLE"
              << endmsg;
          m_state = Gaudi::StateMachine::OFFLINE;
          return StatusCode::FAILURE;
        }

        m_log << MSG::DEBUG << "Will process Errors returned by: " << TAG
            << " -> action: " << VAL << endmsg;

      }

      return status;
    }

ExceptionSvc& ExceptionSvc::operator= | ( | const ExceptionSvc & | ) | `[private]`

no assignement

## Friends And Related Function Documentation

friend class SvcFactory< ExceptionSvc >`[friend]`

Definition at line 25 of file ExceptionSvc.h.

## Member Data Documentation

MsgStream ExceptionSvc::m_log`[mutable, private]`

Definition at line 73 of file ExceptionSvc.h.

Policy ExceptionSvc::m_mode_err`[private]`

Definition at line 69 of file ExceptionSvc.h.

StringProperty ExceptionSvc::m_mode_err_s`[private]`

Definition at line 70 of file ExceptionSvc.h.

Policy ExceptionSvc::m_mode_exc`[private]`

Definition at line 69 of file ExceptionSvc.h.

StringProperty ExceptionSvc::m_mode_exc_s`[private]`

Definition at line 70 of file ExceptionSvc.h.

std::map<std::string,ReturnState> ExceptionSvc::m_retCodesErr`[private]`

Definition at line 71 of file ExceptionSvc.h.

std::map<std::string,ReturnState> ExceptionSvc::m_retCodesExc`[private]`

Definition at line 71 of file ExceptionSvc.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiSvc/src/ExceptionSvc/ExceptionSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiSvc/src/ExceptionSvc/ExceptionSvc.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines