version 1.52, 2002/08/16 01:28:06
|
version 1.53, 2002/08/16 22:48:29
|
|
|
| |
#include <cstdio> | #include <cstdio> |
#include "Exception.h" | #include "Exception.h" |
|
#include <Pegasus/Common/CIMExceptionRep.h> |
#include "Tracer.h" | #include "Tracer.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
// |
CIMException::CIMException( |
// Creates a description without source file name and line number. |
|
// |
|
static String _makeCIMExceptionDescription( |
|
CIMStatusCode code, | CIMStatusCode code, |
const String& message) | const String& message) |
|
: |
|
Exception(message) |
{ | { |
String tmp; |
_rep = new CIMExceptionRep(); |
tmp.append(cimStatusCodeToString(code)); |
_rep->code = code; |
if (message != String::EMPTY) |
_rep->file = ""; |
{ |
_rep->line = 0; |
tmp.append(": \""); |
|
tmp.append(message); |
|
tmp.append("\""); |
|
} |
|
return tmp; |
|
} | } |
| |
// |
CIMException::CIMException(const CIMException & cimException) |
// Creates a description with source file name and line number. |
: Exception(cimException.getMessage()) |
// |
{ |
static String _makeCIMExceptionDescription( |
_rep = new CIMExceptionRep(); |
CIMStatusCode code, |
_rep->code = cimException._rep->code; |
const String& message, |
_rep->file = cimException._rep->file; |
const char* file, |
_rep->line = cimException._rep->line; |
Uint32 line) |
|
{ |
|
String tmp = file; |
|
tmp.append("("); |
|
char buffer[32]; |
|
sprintf(buffer, "%d", line); |
|
tmp.append(buffer); |
|
tmp.append("): "); |
|
tmp.append(_makeCIMExceptionDescription(code, message)); |
|
return tmp; |
|
} | } |
| |
CIMException::CIMException( |
CIMException& CIMException::operator=(const CIMException & cimException) |
CIMStatusCode code, |
|
const String& message, |
|
const char* file, |
|
Uint32 line) |
|
: |
|
Exception(message), |
|
_code(code), |
|
_file(file), |
|
_line(line) |
|
{ | { |
|
_message = cimException._message; |
|
_rep->code = cimException._rep->code; |
|
_rep->file = cimException._rep->file; |
|
_rep->line = cimException._rep->line; |
|
return *this; |
} | } |
| |
// |
CIMException::~CIMException() |
// Returns a description string fit for human consumption |
|
// |
|
String CIMException::getDescription() const |
|
{ | { |
#ifdef DEBUG_CIMEXCEPTION |
delete _rep; |
return getTraceDescription(); |
|
#else |
|
return _makeCIMExceptionDescription(_code, getMessage()); |
|
#endif |
|
} | } |
| |
// |
CIMStatusCode CIMException::getCode() const |
// Returns a description string with filename and line number information |
|
// specifically for tracing. |
|
// |
|
String CIMException::getTraceDescription() const |
|
{ | { |
String traceDescription = |
return _rep->code; |
_makeCIMExceptionDescription(_code, getMessage(), _file, _line); |
|
|
|
return traceDescription; |
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |