16#include "TrkBase/TrkErrCode.h"
21std::string TrkErrCode::_nullStr(
"" );
38 : _failure( theCode._failure ), _success( theCode._success ) {
39 if ( theCode._string != 0 ) { _string = new std::string( *theCode._string ); }
52 _failure = theCode._failure;
53 _success = theCode._success;
55 if ( theCode._string != 0 )
57 if ( _string != 0 ) { *_string = *theCode._string; }
58 else { _string =
new std::string( *theCode._string ); }
62 if ( _string != 0 )
delete _string;
70 const char* pstatus = 0;
74 pstatus =
"succeeded";
83 static const std::string failed[4] = {
"Arithmetic error.",
"Failed to converge.",
84 "Failed because parallel.",
"Undefined error." };
86 static const std::string succeeded[4] = {
"Normal completion.",
"Didn't converge.",
87 "Parallel.",
"Undefined success state." };
89 if ( code > 0 && code < 10 )
91 if (
failure() ) { pstring = failed[std::min( code - 1, 3 )]; }
92 else if (
success() ) { pstring = succeeded[std::min( code - 1, 3 )]; }
94 else if ( _string == 0 ) { pstring =
"Unknown error."; }
95 else { pstring = *_string; }
97 ostr <<
"TrkErrCode: " << pstatus <<
", code " << code <<
". 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)