source: trunk/FACT++/src/DimErrorRedirecter.cc @ 10583

Last change on this file since 10583 was 10583, checked in by tbretz, 9 years ago
Added the right exit handler.
File size: 2.5 KB
Line 
1// **************************************************************************
2/** @class DimErrorRedirecter
3
4*/
5// **************************************************************************
6#include "DimErrorRedirecter.h"
7
8#include <dic.hxx>
9
10#include "WindowLog.h"
11#include "MessageImp.h"
12
13using namespace std;
14
15int DimErrorRedirecter::cnt = 0;
16
17DimErrorRedirecter::DimErrorRedirecter(MessageImp &imp) : fMsg(imp)
18{
19    if (cnt++)
20    {
21        fMsg.Error("ERROR - More than one instance of MyHandlers.");
22        exit(-1);
23    }
24
25    dic_disable_padding();
26    dis_disable_padding();
27
28    DimServer::addExitHandler(this);
29    DimServer::addErrorHandler(this);
30    DimClient::addErrorHandler(this);
31}
32
33DimErrorRedirecter::~DimErrorRedirecter()
34{
35    DimClient::addErrorHandler(0);
36    DimServer::addErrorHandler(0);
37    DimServer::addExitHandler(0);
38}
39
40void DimErrorRedirecter::errorHandler(int severity, int code, char *msg)
41{
42    static const string id = "DIM|";
43
44    switch (severity)
45    {
46    case DIM_FATAL:   fMsg.Error(id+msg); break;
47    case DIM_ERROR:   fMsg.Error(id+msg); break;
48    case DIM_WARNING: fMsg.Warn(id+msg);  break;
49    case DIM_INFO:    fMsg.Info(id+msg);  break;
50    default:
51        stringstream str;
52        str << "DIM message with unknown severity (" << severity << "): ";
53        str << msg << " (" << code << ")";
54        fMsg.Message(str);
55        break;
56    }
57
58    // If the severity is FATAL after this the exitHandler
59    // is called with the errorcode by dim
60
61    //if (severity==DIM_FATAL && code==DIMDNSDUPLC)
62    //    exit(3);//abort();
63
64
65    /*
66     DIMDNSUNDEF        DIM_FATAL       DIM_DNS_NODE undefined
67     DIMDNSREFUS        DIM_FATAL       DIM_DNS refuses connection
68     DIMDNSDUPLC        DIM_FATAL       Service already exists in DNS
69     DIMDNSEXIT         DIM_FATAL       DNS requests server to EXIT
70     DIMDNSTMOUT        DIM_WARNING     Server failed sending Watchdog
71
72     DIMDNSCNERR        DIM_ERROR       Connection to DNS failed
73     DIMDNSCNEST        DIM_INFO        Connection to DNS established
74
75     DIMSVCDUPLC        DIM_ERROR       Service already exists in Server
76     DIMSVCFORMT        DIM_ERROR       Bad format string for service
77     DIMSVCINVAL        DIM_ERROR       Invalid Service ID
78
79     DIMTCPRDERR        DIM_ERROR       TCP/IP read error
80     DIMTCPWRRTY        DIM_WARNING     TCP/IP write error - Retrying
81     DIMTCPWRTMO        DIM_ERROR       TCP/IP write error - Disconnected
82     DIMTCPLNERR        DIM_ERROR       TCP/IP listen error
83     DIMTCPOPERR        DIM_ERROR       TCP/IP open server error
84     DIMTCPCNERR        DIM_ERROR       TCP/IP connection error
85     DIMTCPCNEST        DIM_INFO        TCP/IP connection established
86     */
87}
88
Note: See TracBrowser for help on using the repository browser.