DABC (Data Acquisition Backbone Core)  2.9.9
Exception.cxx
Go to the documentation of this file.
1 // $Id: Exception.cxx 3862 2018-05-11 10:06:18Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #include "dabc/Exception.h"
17 
18 #include "dabc/logging.h"
19 
21  std::exception(),
22  fKind(ex_None),
23  fWhat(),
24  fItem()
25 {
26  DOUT2("Generic exception");
27 }
28 
29 dabc::Exception::Exception(const std::string &info, const std::string &item) throw() :
30  std::exception(),
31  fKind(ex_Generic),
32  fWhat(info),
33  fItem(item)
34 {
35  DOUT2( "Exception %s from item %s", what(), item.c_str());
36 }
37 
38 
39 dabc::Exception::Exception(ExceptionKind _kind, const std::string &info, const std::string &item) throw() :
40  std::exception(),
41  fKind(_kind),
42  fWhat(info),
43  fItem(item)
44 {
45  DOUT2( "Exception %s from item %s", what(), item.c_str());
46 }
47 
48 
50 {
51 }
52 
53 const char* dabc::Exception::what() const throw()
54 {
55  switch(kind()) {
56  case ex_None: return "undefined";
57  case ex_Stop: return "stop";
58  case ex_Timeout: return "timeout";
59  case ex_Input: return "input";
60  case ex_Output: return "output";
61  case ex_Connect: return "connect";
62  case ex_Disconnect: return "disconnect";
63  case ex_Command: return fWhat.c_str();
64  case ex_Buffer: return fWhat.c_str();
65  case ex_Pool: return fWhat.c_str();
66  case ex_Object: return fWhat.c_str();
67  case ex_Hierarchy: return fWhat.c_str();
68  case ex_Pointer: return fWhat.c_str();
69  case ex_Generic: return fWhat.c_str();
70  }
71 
72  return "uncknown";
73 }
virtual const char * what() const
Definition: Exception.cxx:53
virtual ~Exception()
Definition: Exception.cxx:49
#define DOUT2(args ...)
Definition: logging.h:170
ExceptionKind
Definition: Exception.h:27
@ ex_Generic
Definition: Exception.h:41
@ ex_Connect
Definition: Exception.h:33
@ ex_Pool
Definition: Exception.h:37
@ ex_Stop
Definition: Exception.h:29
@ ex_Input
Definition: Exception.h:31
@ ex_Output
Definition: Exception.h:32
@ ex_Command
Definition: Exception.h:35
@ ex_Buffer
Definition: Exception.h:36
@ ex_Disconnect
Definition: Exception.h:34
@ ex_Pointer
Definition: Exception.h:40
@ ex_Hierarchy
Definition: Exception.h:39
@ ex_None
Definition: Exception.h:28
@ ex_Timeout
Definition: Exception.h:30
@ ex_Object
Definition: Exception.h:38