version 1.22.2.5, 2001/09/04 03:08:59
|
version 1.81.4.2, 2008/02/13 20:45:48
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
|
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// 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 |
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Nag Boranna (nagaraja_boranna@hp.com) |
|
// |
|
// Modified By: |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <cstdio> | #include <cstdio> |
#include "Exception.h" | #include "Exception.h" |
|
#include <Pegasus/Common/ExceptionRep.h> |
|
#include <Pegasus/Common/CIMExceptionRep.h> |
|
#include "Tracer.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
Exception::Exception(const String& message) : _message(message) |
Exception::Exception(const String& message) |
{ | { |
|
_rep = new ExceptionRep(); |
|
_rep->message = message; |
|
_rep->contentLanguages.clear(); |
|
} |
| |
|
Exception::Exception(const Exception& exception) |
|
{ |
|
_rep = new ExceptionRep(); |
|
_rep->message = exception._rep->message; |
|
_rep->contentLanguages = exception._rep->contentLanguages; |
} | } |
| |
Exception::Exception(const char* message) : _message(message) |
Exception::Exception(const MessageLoaderParms& msgParms) |
{ | { |
|
_rep = new ExceptionRep(); |
|
_rep->message = MessageLoader::getMessage( |
|
const_cast<MessageLoaderParms &>(msgParms)); |
|
// Must be after MessageLoader::getMessage call |
|
_rep->contentLanguages = msgParms.contentlanguages; |
|
} |
| |
|
Exception::Exception() |
|
{ |
|
_rep = NULL; |
} | } |
| |
Exception::~Exception() | Exception::~Exception() |
{ | { |
|
delete _rep; |
} | } |
| |
AssertionFailureException::AssertionFailureException( |
Exception& Exception::operator=(const Exception& exception) |
const char* file, |
|
size_t line, |
|
const String& message) : Exception(String()) |
|
{ | { |
char lineStr[32]; |
if (&exception != this) |
sprintf(lineStr, "%d", line); |
{ |
|
*this->_rep = *exception._rep; |
_message = file; |
} |
_message.append("("); |
return *this; |
_message.append(lineStr); |
|
_message.append("): "); |
|
_message.append(message); |
|
} | } |
| |
const char OutOfBounds::MSG[] = "out of bounds"; |
const String& Exception::getMessage() const |
|
{ |
const char AlreadyExists::MSG[] = "already exists: "; |
return _rep->message; |
|
} |
const char NullPointer::MSG[] = "null pointer"; |
|
|
|
const char UnitializedHandle::MSG[] = "unitialized handle"; |
|
|
|
const char IllegalName::MSG[] = "illegal CIM name"; |
|
|
|
const char InvalidPropertyOverride::MSG[] = "invalid property override: "; |
|
|
|
const char InvalidMethodOverride::MSG[] = "invalid method override: "; |
|
|
|
const char UndeclaredQualifier::MSG[] = "undeclared qualifier: "; |
|
|
|
const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: "; |
|
|
|
const char BadQualifierOverride::MSG[] = "qualifier not overridable: "; |
|
|
|
const char BadQualifierType::MSG[] = |
|
"CIMType of qualifier different than its declaration: "; |
|
|
|
const char NullType::MSG[] = "type is null"; |
|
|
|
const char AddedReferenceToClass::MSG[] = |
|
"attempted to add reference to a non-association class: "; |
|
|
|
const char ClassAlreadyResolved::MSG[] = |
|
"attempt to resolve a class that is already resolved: "; |
|
|
|
const char ClassNotResolved::MSG[] = |
|
"class is not yet resolved: "; |
|
|
|
const char InstanceAlreadyResolved::MSG[] = |
|
"attempted to resolve a instance that is already resolved"; |
|
|
|
const char InstantiatedAbstractClass::MSG[] = |
|
"attempted to instantiated an abstract class"; |
|
|
|
const char NoSuchProperty::MSG[] = "no such property: "; |
|
|
|
const char TruncatedCharacter::MSG[] = |
|
"truncated character during conversion from Char16 to char"; |
|
|
|
const char ExpectedReferenceValue::MSG[] = |
|
"Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY " |
|
"in this context"; |
|
|
|
const char MissingReferenceClassName::MSG[] = "missing reference class name"; |
|
| |
const char IllegalTypeTag::MSG[] = "illegal type tag"; |
const ContentLanguageList& Exception::getContentLanguages() const |
|
{ |
|
return _rep->contentLanguages; |
|
} |
| |
const char TypeMismatch::MSG[] = "type mismatch"; |
void Exception::setContentLanguages(const ContentLanguageList& langs) |
|
{ |
|
_rep->contentLanguages = langs; |
|
} |
| |
const char NoSuchFile::MSG[] = "no such file: "; |
IndexOutOfBoundsException::IndexOutOfBoundsException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INDEX_OUT_OF_BOUNDS_EXCEPTION", |
|
"index out of bounds")) |
|
{ |
|
} |
| |
const char FileNotReadable::MSG[] = "file not readable: "; |
AlreadyExistsException::AlreadyExistsException(const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.ALREADY_EXISTS_EXCEPTION", |
|
"already exists: $0", |
|
message)) |
|
{ |
|
} |
| |
const char CannotBindToAddress::MSG[] = "cannot bind to address: "; |
AlreadyExistsException::AlreadyExistsException(MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.ALREADY_EXISTS_EXCEPTION", |
|
"already exists: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char NoSuchDirectory::MSG[] = "no such directory: "; |
InvalidNameException::InvalidNameException(const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INVALID_NAME_EXCEPTION", |
|
"invalid CIM name: $0", |
|
message)) |
|
{ |
|
} |
| |
const char ChangeDirectoryFailed::MSG[] = "cannot change directory: "; |
InvalidNameException::InvalidNameException(MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INVALID_NAME_EXCEPTION", |
|
"invalid CIM name: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char CannotCreateDirectory::MSG[] = "cannot create directory: "; |
InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INVALID_NAMESACE_NAME_EXCEPTION", |
|
"invalid CIM namespace name: $0", |
|
name)) |
|
{ |
|
} |
| |
const char NoSuchNameSpace::MSG[] = "no such namespace: "; |
InvalidNamespaceNameException::InvalidNamespaceNameException( |
|
MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INVALID_NAMESPACE_NAME_EXCEPTION", |
|
"invalid CIM namespace name: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char CannotOpenFile::MSG[] = "cannot open file: "; |
UninitializedObjectException::UninitializedObjectException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", |
|
"uninitialized object")) |
|
{ |
|
} |
| |
const char NotImplemented::MSG[] = "not implemented: "; |
TypeMismatchException::TypeMismatchException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.TYPE_MISMATCH_EXCEPTION", |
|
"type mismatch")) |
|
{ |
|
} |
| |
const char CannotRemoveDirectory::MSG[] = "cannot remove directory: "; |
TypeMismatchException::TypeMismatchException(const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.TYPE_MISMATCH_EXCEPTION", |
|
"type mismatch: $0",message)) |
|
{ |
| |
const char CannotRemoveFile::MSG[] = "cannot remove file: "; |
} |
| |
const char CannotRenameFile::MSG[] = "cannot rename file: "; |
TypeMismatchException::TypeMismatchException(MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.TYPE_MISMATCH_EXCEPTION", |
|
"type mismatch: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char StackUnderflow::MSG[] = "stack underflow"; |
DynamicCastFailedException::DynamicCastFailedException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.DYNAMIC_CAST_FAILED_EXCEPTION", |
|
"dynamic cast failed")) |
|
{ |
|
} |
| |
const char StackOverflow::MSG[] = "stack overflow"; |
InvalidDateTimeFormatException::InvalidDateTimeFormatException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INVALID_DATETIME_FORMAT_EXCEPTION", |
|
"invalid datetime format")) |
|
{ |
|
} |
| |
const char QueueUnderflow::MSG[] = "queue Underflow"; |
MalformedObjectNameException::MalformedObjectNameException( |
|
const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION", |
|
"malformed object name: $0", |
|
message)) |
|
{ |
|
} |
| |
const char BadFormat::MSG[] = "bad format passed to Formatter::format()"; |
MalformedObjectNameException::MalformedObjectNameException( |
|
MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION", |
|
"malformed object name: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char BadDateTimeFormat::MSG[] = "bad datetime format"; |
BindFailedException::BindFailedException(const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.BIND_FAILED_EXCEPTION", |
|
"Bind failed: $0", |
|
message)) |
|
{ |
|
} |
| |
const char IncompatibleTypes::MSG[] = "incompatible types"; |
BindFailedException::BindFailedException(MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.BIND_FAILED_EXCEPTION", |
|
"Bind failed: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string"; |
InvalidLocatorException::InvalidLocatorException(const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INVALID_LOCATOR_EXCEPTION", |
|
"Invalid locator: $0", |
|
message)) |
|
{ |
|
} |
| |
const char IllformedObjectName::MSG[] = "illformed object name: "; |
InvalidLocatorException::InvalidLocatorException(MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.INVALID_LOCATOR_EXCEPTION", |
|
"Invalid locator: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: "; |
CannotCreateSocketException::CannotCreateSocketException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.CANNOT_CREATE_SOCKET_EXCEPTION", |
|
"Cannot create socket")) |
|
{ |
|
} |
| |
const char DynamicLookupFailed::MSG[] = |
|
"lookup of symbol in dynamic library failed: "; |
|
| |
const char CannotOpenDirectory::MSG[] = "cannot open directory: "; |
CannotConnectException::CannotConnectException(const String& message)//??? |
|
: Exception(message) |
|
{ |
|
} |
| |
const char CorruptFile::MSG[] = "corrupt file: "; |
|
| |
const char BindFailed::MSG[] = "Bind failed: "; |
CannotConnectException::CannotConnectException(MessageLoaderParms& msgParms) |
|
: Exception(msgParms) |
|
{ |
|
} |
| |
const char InvalidLocator::MSG[] = "Invalid locator: "; |
AlreadyConnectedException::AlreadyConnectedException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.ALREADY_CONNECTED_EXCEPTION", |
|
"already connected")) |
|
{ |
|
} |
| |
const char CannotCreateSocket::MSG[] = "Cannot create socket"; |
|
| |
const char CannotConnect::MSG[] = "Cannot connect to: "; |
NotConnectedException::NotConnectedException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.NOT_CONNECTED_EXCEPTION", |
|
"not connected")) |
|
{ |
|
} |
| |
const char UnexpectedFailure::MSG[] = "Unexpected failure"; |
ConnectionTimeoutException::ConnectionTimeoutException() |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.CONNECTION_TIMEOUT_EXCEPTION", |
|
"connection timed out")) |
|
{ |
|
} |
| |
const char FailedToConnect::MSG[] = "failed to connect"; |
SSLException::SSLException(const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.SSL_EXCEPTION", |
|
"SSL Exception: $0" , |
|
message)) |
|
{ |
|
} |
| |
const char AlreadyConnected::MSG[] = "already connected"; |
SSLException::SSLException(MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.SSL_EXCEPTION", |
|
"SSL Exception: $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
const char NotConnected::MSG[] = "not connected"; |
DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION", |
|
"DateTime is out of range : $0" , |
|
message)) |
|
{ |
|
} |
| |
const char TimedOut::MSG[] = "timed out"; |
DateTimeOutOfRangeException::DateTimeOutOfRangeException( |
|
MessageLoaderParms& msgParms) |
|
: Exception(MessageLoaderParms( |
|
"Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION", |
|
"DateTime is out of range : $0", |
|
MessageLoader::getMessage(msgParms))) |
|
{ |
|
} |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
static String _makeCIMExceptionMessage( |
// l10n - note - use this when you have an exception with no |
|
// detail message, or one with an untranslated detail message |
|
// The pegasus message associated with code will be translated. |
|
CIMException::CIMException( |
|
CIMStatusCode code, |
|
const String& message) |
|
: Exception() |
|
{ |
|
CIMExceptionRep * tmp = new CIMExceptionRep (); |
|
tmp->message = message; |
|
tmp->code = code; |
|
tmp->file = ""; |
|
tmp->line = 0; |
|
tmp->contentLanguages.clear(); |
|
tmp->cimMessage = String::EMPTY; |
|
_rep = tmp; |
|
} |
|
|
|
|
|
// l10n - note - use this when you have an exception |
|
// an untranslated detail message and an attached CIM_Error |
|
// The pegasus message associated with code will be translated. |
|
CIMException::CIMException( |
|
CIMStatusCode code, |
|
const String& message, |
|
const CIMInstance& instance) |
|
: Exception() |
|
{ |
|
CIMExceptionRep * tmp = new CIMExceptionRep (); |
|
tmp->message = message; |
|
tmp->code = code; |
|
tmp->file = ""; |
|
tmp->errors.append(instance); |
|
tmp->line = 0; |
|
tmp->contentLanguages.clear(); |
|
tmp->cimMessage = String::EMPTY; |
|
_rep = tmp; |
|
} |
|
|
|
// l10n - note - use this when you have an exception |
|
// an untranslated detail message and an attached CIM_Error |
|
// array |
|
// The pegasus message associated with code will be translated. |
|
CIMException::CIMException( |
|
CIMStatusCode code, |
|
const String& message, |
|
const Array<CIMInstance>& instances) |
|
: Exception() |
|
{ |
|
CIMExceptionRep * tmp = new CIMExceptionRep (); |
|
tmp->message = message; |
|
tmp->code = code; |
|
tmp->file = ""; |
|
tmp->errors.appendArray(instances); |
|
tmp->line = 0; |
|
tmp->contentLanguages.clear(); |
|
tmp->cimMessage = String::EMPTY; |
|
_rep = tmp; |
|
} |
|
// l10n - note use this when you have an exception with a translated |
|
// detail message |
|
CIMException::CIMException( |
CIMStatusCode code, | CIMStatusCode code, |
const char* file, |
const MessageLoaderParms& msgParms) |
Uint32 line, |
: Exception() |
const String& extraMessage) |
|
{ | { |
String tmp = file; |
CIMExceptionRep* tmp = new CIMExceptionRep(); |
tmp.append("("); |
tmp->message = MessageLoader::getMessage( |
char buffer[32]; |
const_cast<MessageLoaderParms &>(msgParms)); |
sprintf(buffer, "%d", line); |
// Must be after MessageLoader::getMessage call |
tmp.append(buffer); |
tmp->contentLanguages = msgParms.contentlanguages; |
tmp.append("): "); |
tmp->cimMessage = String::EMPTY; |
|
tmp->code = code; |
|
tmp->file = ""; |
|
tmp->line = 0; |
|
_rep = tmp; |
|
} |
| |
tmp.append(CIMStatusCodeToString(code)); |
CIMException::CIMException( |
tmp.append(": \""); |
CIMStatusCode code, |
tmp.append(extraMessage); |
const MessageLoaderParms& msgParms, |
tmp.append("\""); |
const CIMInstance& instance) |
return tmp; |
: Exception() |
|
{ |
|
CIMExceptionRep* tmp = new CIMExceptionRep(); |
|
tmp->message = MessageLoader::getMessage( |
|
const_cast<MessageLoaderParms &>(msgParms)); |
|
// Must be after MessageLoader::getMessage call |
|
tmp->contentLanguages = msgParms.contentlanguages; |
|
tmp->cimMessage = String::EMPTY; |
|
tmp->errors.append(instance); |
|
tmp->code = code; |
|
tmp->file = ""; |
|
tmp->line = 0; |
|
_rep = tmp; |
} | } |
| |
CIMException::CIMException( | CIMException::CIMException( |
CIMStatusCode code, | CIMStatusCode code, |
const char* file, |
const MessageLoaderParms& msgParms, |
Uint32 line, |
const Array<CIMInstance>& instances) |
const String& extraMessage) |
: Exception() |
: Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)), |
{ |
_code(code) |
CIMExceptionRep* tmp = new CIMExceptionRep(); |
|
tmp->message = MessageLoader::getMessage( |
|
const_cast<MessageLoaderParms &>(msgParms)); |
|
// Must be after MessageLoader::getMessage call |
|
tmp->contentLanguages = msgParms.contentlanguages; |
|
tmp->cimMessage = String::EMPTY; |
|
tmp->errors.appendArray(instances); |
|
tmp->code = code; |
|
tmp->file = ""; |
|
tmp->line = 0; |
|
_rep = tmp; |
|
} |
|
|
|
CIMException::CIMException(const CIMException & cimException) |
|
: Exception() |
|
{ |
|
_rep = new CIMExceptionRep( |
|
*reinterpret_cast<CIMExceptionRep*>(cimException._rep)); |
|
} |
|
|
|
CIMException& CIMException::operator=(const CIMException & cimException) |
|
{ |
|
if (&cimException != this) |
{ | { |
|
CIMExceptionRep* left = reinterpret_cast<CIMExceptionRep*>(this->_rep); |
|
CIMExceptionRep* right = |
|
reinterpret_cast<CIMExceptionRep*>(cimException._rep); |
|
*left = *right; |
|
} |
|
return *this; |
|
} |
| |
|
CIMException::~CIMException() |
|
{ |
|
} |
|
|
|
Uint32 CIMException::getErrorCount() const |
|
{ |
|
return reinterpret_cast<CIMExceptionRep*>(_rep)->errors.size(); |
|
} |
|
/************** |
|
CIMInstance CIMException::getError(Uint32 index) |
|
{ |
|
return reinterpret_cast<CIMExceptionRep*>(_rep)->errors[index]; |
|
} |
|
***************/ |
|
|
|
CIMConstInstance CIMException::getError(Uint32 index) const |
|
{ |
|
return reinterpret_cast<CIMExceptionRep*>(_rep)->errors[index]; |
|
} |
|
|
|
void CIMException::addError(const CIMInstance& instance) |
|
{ |
|
reinterpret_cast<CIMExceptionRep*>(_rep)->errors.append(instance); |
} | } |
| |
void ThrowUnitializedHandle() |
CIMStatusCode CIMException::getCode() const |
{ | { |
throw UnitializedHandle(); |
CIMExceptionRep* rep; |
|
rep = reinterpret_cast<CIMExceptionRep*>(_rep); |
|
return rep->code; |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |