forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrordesc.cc
More file actions
169 lines (150 loc) · 4.42 KB
/
errordesc.cc
File metadata and controls
169 lines (150 loc) · 4.42 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* NIST Utils Class Library
* clutils/errordesc.cc
* February, 1993
* David Sauder
* K. C. Morris
* Development of this software was funded by the United States Government,
* and is not subject to copyright.
*/
/* $Id: errordesc.cc,v 3.0.1.2 1997/11/05 22:33:46 sauderd DP3.1 $ */
#include <errordesc.h>
#include <Str.h>
#include <scl_memmgr.h>
DebugLevel ErrorDescriptor::_debug_level = DEBUG_OFF;
ostream * ErrorDescriptor::_out = 0;
void
ErrorDescriptor::PrintContents( ostream & out ) const {
std::string s;
severity( s );
out << "Severity: " << s << endl;
if( !_userMsg.empty() ) {
out << "User message in parens:" << endl << "(";
out << UserMsg() << ")" << endl;
}
if( !_detailMsg.empty() ) {
out << "Detailed message in parens:" << endl << "(";
out << DetailMsg() << ")" << endl;
}
}
void ErrorDescriptor::severity( std::string & s ) const {
s.clear();
switch( severity() ) {
case SEVERITY_NULL : {
s.assign( "SEVERITY_NULL" );
break;
}
case SEVERITY_USERMSG : {
s.assign( "SEVERITY_USERMSG" );
break;
}
case SEVERITY_INCOMPLETE : {
s.assign( "SEVERITY_INCOMPLETE" );
break;
}
case SEVERITY_WARNING : {
s.assign( "SEVERITY_WARNING" );
break;
}
case SEVERITY_INPUT_ERROR : {
s.assign( "SEVERITY_INPUT_ERROR" );
break;
}
case SEVERITY_BUG : {
s.assign( "SEVERITY_BUG" );
break;
}
case SEVERITY_EXIT : {
s.assign( "SEVERITY_EXIT" );
break;
}
case SEVERITY_DUMP : {
s.assign( "SEVERITY_DUMP" );
break;
}
case SEVERITY_MAX : {
s.assign( "SEVERITY_MAX" );
break;
}
}
}
Severity
ErrorDescriptor::GetCorrSeverity( const char * s ) {
// cout << "s is (" << s << ") \n";
if( s && s[0] != 0 ) {
std::string s2;
StrToUpper( s, s2 );
// cout << "s after if is (" << s << ") \n" << "s2 is (" << s2 << ")\n";
if( !s2.compare( "SEVERITY_NULL" ) ) {
// cout << "SEVERITY_NULL" << endl;
return SEVERITY_NULL;
}
if( !s2.compare( "SEVERITY_USERMSG" ) ) {
// cout << "SEVERITY_USERMSG" << endl;
return SEVERITY_USERMSG;
}
if( !s2.compare( "SEVERITY_INCOMPLETE" ) ) {
// cout << "SEVERITY_INCOMPLETE" << endl;
return SEVERITY_INCOMPLETE;
}
if( !s2.compare( "SEVERITY_WARNING" ) ) {
// cout << "SEVERITY_WARNING" << endl;
return SEVERITY_WARNING;
}
if( !s2.compare( "SEVERITY_INPUT_ERROR" ) ) {
// cout << "SEVERITY_INPUT_ERROR" << endl;
return SEVERITY_INPUT_ERROR;
}
if( !s2.compare( "SEVERITY_BUG" ) ) {
// cout << "SEVERITY_BUG" << endl;
return SEVERITY_BUG;
}
if( !s2.compare( "SEVERITY_EXIT" ) ) {
// cout << "SEVERITY_EXIT" << endl;
return SEVERITY_EXIT;
}
if( !s2.compare( "SEVERITY_DUMP" ) ) {
// cout << "SEVERITY_DUMP" << endl;
return SEVERITY_DUMP;
}
if( !s2.compare( "SEVERITY_MAX" ) ) {
// cout << "SEVERITY_MAX" << endl;
return SEVERITY_MAX;
}
}
cerr << "Internal error: " << __FILE__ << __LINE__
<< "\n" << _POC_ "\n";
cerr << "Calling ErrorDescriptor::GetCorrSeverity() with null string\n";
return SEVERITY_BUG;
}
ErrorDescriptor::ErrorDescriptor( Severity s, DebugLevel d ) : _severity( s ) {
if( d != DEBUG_OFF ) {
_debug_level = d;
}
}
ErrorDescriptor::~ErrorDescriptor( void ) {
}
void ErrorDescriptor::UserMsg( const char * msg ) {
_userMsg.assign( msg );
}
void ErrorDescriptor::PrependToUserMsg( const char * msg ) {
_userMsg.insert( 0, msg );
}
void ErrorDescriptor::AppendToUserMsg( const char c ) {
_userMsg.append( &c );
}
void ErrorDescriptor::AppendToUserMsg( const char * msg ) {
_userMsg.append( msg );
}
void ErrorDescriptor::DetailMsg( const char * msg ) {
_detailMsg.assign( msg );
}
void ErrorDescriptor::PrependToDetailMsg( const char * msg ) {
_detailMsg.insert( 0, msg );
}
void ErrorDescriptor::AppendToDetailMsg( const char c ) {
_detailMsg.append( &c );
}
void ErrorDescriptor::AppendToDetailMsg( const char * msg ) {
_detailMsg.append( msg );
}