Changeset 10511 for trunk/FACT++/src


Ignore:
Timestamp:
05/02/11 19:05:09 (14 years ago)
Author:
tbretz
Message:
Added exit handler; call exit handler in case of fatal error; add Dim id to messages.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/DimErrorRedirecter.cc

    r10479 r10511  
    2727
    2828    DimClient::addErrorHandler(this);
     29    DimServer::addExitHandler(this);
    2930}
    3031
     
    3233{
    3334    DimClient::addErrorHandler(0);
     35    DimServer::addExitHandler(0);
    3436}
    3537
    3638void DimErrorRedirecter::errorHandler(int severity, int code, char *msg)
    3739{
     40    static const string id = "DIM|";
     41
    3842    switch (severity)
    3943    {
    40     case DIM_FATAL:   fMsg.Error(msg); return;
    41     case DIM_ERROR:   fMsg.Error(msg); return;
    42     case DIM_WARNING: fMsg.Warn(msg);  return;
    43     case DIM_INFO:    fMsg.Info(msg);  return;
     44    case DIM_FATAL:   fMsg.Error(id+msg); break;
     45    case DIM_ERROR:   fMsg.Error(id+msg); break;
     46    case DIM_WARNING: fMsg.Warn(id+msg);  break;
     47    case DIM_INFO:    fMsg.Info(id+msg);  break;
     48    default:
     49        stringstream str;
     50        str << "DIM message with unknown severity (" << severity << "): ";
     51        str << msg << " (" << code << ")";
     52        fMsg.Message(str);
     53        break;
    4454    }
    4555
    46     stringstream str;
    47     str << "Severity of Dim message unknown(" << severity << "): ";
    48     str << msg << "(" << code << ")";
    49     fMsg.Message(str);
     56    if (severity==DIM_FATAL && code==DIMDNSDUPLC)
     57        exitHandler(DIMDNSDUPLC);
    5058
    5159    /*
  • trunk/FACT++/src/DimErrorRedirecter.h

    r10384 r10511  
    22#define FACT_DimErrorRedirecter
    33
    4 #include <dim.hxx>
     4#include <dis.hxx>
    55
    66class MessageImp;
    77
    8 class DimErrorRedirecter : public DimErrorHandler
     8class DimErrorRedirecter : public DimErrorHandler, public DimExitHandler
    99{
    1010private:
     
    1414
    1515    void errorHandler(int severity, int code, char *msg);
     16    void exitHandler(int code) { exit(code); }
    1617
    1718public:
    1819    DimErrorRedirecter(MessageImp &imp);
    1920    ~DimErrorRedirecter();
    20 
    2121};
    2222
Note: See TracChangeset for help on using the changeset viewer.