version 1.23, 2001/12/13 14:53:56
|
version 1.51, 2002/08/15 15:52:29
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
|
// The Open Group, Tivoli Systems |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Modified By: Nag Boranna (nagaraja_boranna@hp.com) | // Modified By: Nag Boranna (nagaraja_boranna@hp.com) |
// | // |
// Modified By: |
// Modified By: Jenny Yu (jenny_yu@am.exch.hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <cstdio> | #include <cstdio> |
#include "Exception.h" | #include "Exception.h" |
|
#include "Tracer.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
const String& message) : Exception(String()) | const String& message) : Exception(String()) |
{ | { |
char lineStr[32]; | char lineStr[32]; |
sprintf(lineStr, "%d", line); |
sprintf(lineStr, "%u", line); |
| |
_message = file; | _message = file; |
_message.append("("); | _message.append("("); |
_message.append(lineStr); | _message.append(lineStr); |
_message.append("): "); | _message.append("): "); |
_message.append(message); | _message.append(message); |
|
|
|
// ATTN-RK-P3-20020408: Should define a "test" trace component |
|
PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2, _message); |
} | } |
| |
const char OutOfBounds::MSG[] = "out of bounds"; | const char OutOfBounds::MSG[] = "out of bounds"; |
|
|
| |
const char NullPointer::MSG[] = "null pointer"; | const char NullPointer::MSG[] = "null pointer"; |
| |
const char UnitializedHandle::MSG[] = "unitialized handle"; |
const char UninitializedHandle::MSG[] = "uninitialized handle"; |
|
|
|
const char UninitializedObject::MSG[] = "uninitialized object"; |
| |
const char IllegalName::MSG[] = "illegal CIM name"; | const char IllegalName::MSG[] = "illegal CIM name"; |
| |
|
const char IllegalNamespaceName::MSG[] = "illegal CIM namespace name"; |
|
|
const char InvalidPropertyOverride::MSG[] = "invalid property override: "; | const char InvalidPropertyOverride::MSG[] = "invalid property override: "; |
| |
const char InvalidMethodOverride::MSG[] = "invalid method override: "; | const char InvalidMethodOverride::MSG[] = "invalid method override: "; |
|
|
"attempted to resolve a instance that is already resolved"; | "attempted to resolve a instance that is already resolved"; |
| |
const char InstantiatedAbstractClass::MSG[] = | const char InstantiatedAbstractClass::MSG[] = |
"attempted to instantiated an abstract class"; |
"attempted to instantiate an abstract class "; |
| |
const char NoSuchProperty::MSG[] = "no such property: "; | const char NoSuchProperty::MSG[] = "no such property: "; |
| |
|
|
"truncated character during conversion from Char16 to char"; | "truncated character during conversion from Char16 to char"; |
| |
const char ExpectedReferenceValue::MSG[] = | const char ExpectedReferenceValue::MSG[] = |
"Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY " |
"Expected CIMValue object to be of type reference " |
"in this context"; | "in this context"; |
| |
const char MissingReferenceClassName::MSG[] = "missing reference class name"; | const char MissingReferenceClassName::MSG[] = "missing reference class name"; |
|
|
| |
const char TypeMismatch::MSG[] = "type mismatch"; | const char TypeMismatch::MSG[] = "type mismatch"; |
| |
|
const char CIMValueIsNull::MSG[] = "null CIMValue accessed"; |
|
|
|
const char CIMValueInvalidType::MSG[] = "invalid CIMValue type"; |
|
|
|
const char DynamicCastFailed::MSG[] = "dynamic cast failed"; |
|
|
const char NoSuchFile::MSG[] = "no such file: "; | const char NoSuchFile::MSG[] = "no such file: "; |
| |
const char FileNotReadable::MSG[] = "file not readable: "; | const char FileNotReadable::MSG[] = "file not readable: "; |
|
|
| |
const char UnexpectedFailure::MSG[] = "Unexpected failure"; | const char UnexpectedFailure::MSG[] = "Unexpected failure"; |
| |
const char FailedToConnect::MSG[] = "failed to connect"; |
|
|
|
const char AlreadyConnected::MSG[] = "already connected"; | const char AlreadyConnected::MSG[] = "already connected"; |
| |
const char NotConnected::MSG[] = "not connected"; | const char NotConnected::MSG[] = "not connected"; |
|
|
| |
const char SSL_Exception::MSG[] = "SSL Exception "; | const char SSL_Exception::MSG[] = "SSL Exception "; |
| |
|
const char InvalidAuthHeader::MSG[] = "Invalid Authorization header"; |
|
|
|
const char UnauthorizedAccess::MSG[] = "Unauthorized access"; |
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
// CIMException | // CIMException |
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
static String _makeCIMExceptionMessage( |
// |
|
// Creates a description without source file name and line number. |
|
// |
|
static String _makeCIMExceptionDescription( |
|
CIMStatusCode code, |
|
const String& message) |
|
{ |
|
String tmp; |
|
tmp.append(cimStatusCodeToString(code)); |
|
if (message != String::EMPTY) |
|
{ |
|
tmp.append(": \""); |
|
tmp.append(message); |
|
tmp.append("\""); |
|
} |
|
return tmp; |
|
} |
|
|
|
// |
|
// Creates a description with source file name and line number. |
|
// |
|
static String _makeCIMExceptionDescription( |
CIMStatusCode code, | CIMStatusCode code, |
|
const String& message, |
const char* file, | const char* file, |
Uint32 line, |
Uint32 line) |
const String& extraMessage) |
|
{ | { |
String tmp = file; | String tmp = file; |
tmp.append("("); | tmp.append("("); |
|
|
sprintf(buffer, "%d", line); | sprintf(buffer, "%d", line); |
tmp.append(buffer); | tmp.append(buffer); |
tmp.append("): "); | tmp.append("): "); |
|
tmp.append(_makeCIMExceptionDescription(code, message)); |
tmp.append(CIMStatusCodeToString(code)); |
|
tmp.append(": \""); |
|
tmp.append(extraMessage); |
|
tmp.append("\""); |
|
return tmp; | return tmp; |
} | } |
| |
CIMException::CIMException( | CIMException::CIMException( |
CIMStatusCode code, | CIMStatusCode code, |
|
const String& message, |
const char* file, | const char* file, |
Uint32 line, |
Uint32 line) |
const String& extraMessage) |
: |
: Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)), |
Exception(message), |
_code(code) |
_code(code), |
|
_file(file), |
|
_line(line) |
{ | { |
| |
} | } |
| |
void ThrowUnitializedHandle() |
// |
|
// Returns a description string fit for human consumption |
|
// |
|
String CIMException::getDescription() const |
|
{ |
|
#ifdef DEBUG_CIMEXCEPTION |
|
return getTraceDescription(); |
|
#else |
|
return _makeCIMExceptionDescription(_code, getMessage()); |
|
#endif |
|
} |
|
|
|
// |
|
// Returns a description string with filename and line number information |
|
// specifically for tracing. |
|
// |
|
String CIMException::getTraceDescription() const |
{ | { |
throw UnitializedHandle(); |
String traceDescription = |
|
_makeCIMExceptionDescription(_code, getMessage(), _file, _line); |
|
|
|
return traceDescription; |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |