Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//============================================================================//
// A exception class for PRad Event Viewer //
// //
// Chao Peng //
// 02/27/2016 //
//============================================================================//
#include "PRadException.h"
using namespace std;
PRadException::PRadException(const string &typ, const string &txt, const string &aux)
: title(typ), text(txt), auxText(aux)
{
}
PRadException::PRadException(PRadExceptionType typ, const string &txt, const string &aux)
: type(typ), text(txt), auxText(aux)
{
}
PRadException::PRadException(PRadExceptionType typ, const string &txt, const string &file, const string &func, int line)
: type(typ), text(txt)
{
ostringstream oss;
oss << " evioException occured in file " << file << ", function " << func << ", line " << line;
auxText=oss.str();
}
string PRadException::FailureDesc(void) const
{
ostringstream oss;
oss << text << endl
<< auxText;
return(oss.str());
}
string PRadException::FailureType(void) const
{
if(!title.empty())
return title;
string oss;
switch(type)
{
case ET_CONNECT_ERROR:
oss = "ET CONNECT ERROR";
break;
case ET_CONFIG_ERROR:
oss = "ET CONFIG ERROR";
break;
case ET_STATION_CONFIG_ERROR:
oss = "ET STATION CONFIG ERROR";
break;
case ET_STATION_CREATE_ERROR:
oss = "ET STATION CREATE ERROR";
break;
case ET_STATION_ATTACH_ERROR:
oss = "ET ATTACH ERROR";
break;
case ET_READ_ERROR:
oss = "ET READ ERROR";
break;
case ET_PUT_ERROR:
oss = "ET PUT ERROR";
break;
case HIGH_VOLTAGE_ERROR:
oss = "HIGH VOLTAGE SYSTEM ERROR";
break;
default:
oss = "UNKNOWN ERROR";
break;
}
return(oss);
}
const char* PRadException::what() const noexcept
{
string failure = FailureType() + ": " + FailureDesc();
return failure.c_str();
}