16#include "TrkBase/TrkErrCode.h"
21std::string TrkErrCode::_nullStr(
"");
28 _failure = 0; _success = code;
30 _success = 0; _failure = code;
36 : _failure(theCode._failure)
37 , _success(theCode._success)
39 if (theCode._string != 0) {
40 _string =
new std::string(*theCode._string);
58 _failure = theCode._failure;
59 _success = theCode._success;
61 if (theCode._string != 0) {
63 *_string = *theCode._string;
66 _string =
new std::string(*theCode._string);
70 if (_string != 0)
delete _string;
81 const char* pstatus = 0;
84 pstatus =
"succeeded";
91 static const std::string failed[4] = {
"Arithmetic error.",
92 "Failed to converge.",
93 "Failed because parallel.",
96 static const std::string succeeded[4] = {
"Normal completion.",
99 "Undefined success state."};
101 if (code > 0 && code < 10) {
103 pstring = failed[std::min(code-1,3) ];
105 pstring = succeeded[std::min(code-1,3) ];
107 }
else if (_string == 0 ) {
108 pstring =
"Unknown error.";
113 ostr <<
"TrkErrCode: " << pstatus <<
", code " << code
114 <<
". Status: " << pstring.c_str();
ostream & operator<<(ostream &os, const TrkErrCode &trkerr)
void print(std::ostream &ostr) const
TrkErrCode & operator=(const TrkErrCode &)
TrkErrCode(TrkSuccess=succeed, int code=1, const char *str=0)
void setMessage(const char *str=0)