version 1.14, 2001/05/24 00:48:36
|
version 1.55, 2002/08/20 17:39:37
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 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 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// copy of this software and associated documentation files (the "Software"), |
// of this software and associated documentation files (the "Software"), to |
// to deal in the Software without restriction, including without limitation |
// deal in the Software without restriction, including without limitation the |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// and/or sell copies of the Software, and to permit persons to whom the |
// sell copies of the Software, and to permit persons to whom the Software is |
// Software is furnished to do so, subject to the following conditions: |
// furnished to do so, subject to the following conditions: |
// |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// DEALINGS IN THE SOFTWARE. |
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) | // Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// Modified By: |
// Modified By: Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) |
|
// Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <cstdio> | #include <cstdio> |
#include "Exception.h" | #include "Exception.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) : _message(message) |
{ | { |
|
|
} |
|
|
|
Exception::Exception(const char* message) : _message(message) |
|
{ |
|
|
|
} | } |
| |
Exception::~Exception() | Exception::~Exception() |
{ | { |
|
|
} | } |
| |
AssertionFailureException::AssertionFailureException( |
const String& Exception::getMessage() const |
const char* file, |
|
size_t line, |
|
const String& message) : Exception(String()) |
|
{ | { |
char lineStr[32]; |
return _message; |
sprintf(lineStr, "%d", line); |
|
|
|
_message = file; |
|
_message.append("("); |
|
_message.append(lineStr); |
|
_message.append("): "); |
|
_message.append(message); |
|
} | } |
| |
const char OutOfBounds::MSG[] = "out of bounds"; |
|
|
|
const char AlreadyExists::MSG[] = "already exists: "; |
|
|
|
const char NullPointer::MSG[] = "null pointer"; |
|
|
|
const char UnitializedHandle::MSG[] = "unitialized reference"; |
|
|
|
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: "; |
IndexOutOfBoundsException::IndexOutOfBoundsException() |
|
: Exception("index out of bounds") |
|
{ |
|
} |
| |
const char TruncatedCharacter::MSG[] = |
AlreadyExistsException::AlreadyExistsException(const String& message) |
"truncated character during conversion from Char16 to char"; |
: Exception("already exists: " + message) |
|
{ |
|
} |
| |
const char ExpectedReferenceValue::MSG[] = |
InvalidNameException::InvalidNameException(const String& name) |
"Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY " |
: Exception("invalid CIM name: " + name) |
"in this context"; |
{ |
|
} |
| |
const char MissingReferenceClassName::MSG[] = "missing reference class name"; |
InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name) |
|
: Exception("invalid CIM namespace name: " + name) |
|
{ |
|
} |
| |
const char IllegalTypeTag::MSG[] = "illegal type tag"; |
UninitializedHandleException::UninitializedHandleException() |
|
: Exception("uninitialized handle") |
|
{ |
|
} |
| |
const char TypeMismatch::MSG[] = "type mismatch"; |
UninitializedObjectException::UninitializedObjectException() |
|
: Exception("uninitialized object") |
|
{ |
|
} |
| |
const char NoSuchFile::MSG[] = "no such file: "; |
ExpectedReferenceValueException::ExpectedReferenceValueException() |
|
: Exception("Expected CIMValue object to be of type reference " |
|
"in this context") |
|
{ |
|
} |
| |
const char NoSuchDirectory::MSG[] = "no such directory: "; |
MissingReferenceClassNameException::MissingReferenceClassNameException() |
|
: Exception("missing reference class name") |
|
{ |
|
} |
| |
const char ChangeDirectoryFailed::MSG[] = "failed to change directory: "; |
TypeMismatchException::TypeMismatchException() |
|
: Exception("type mismatch") |
|
{ |
|
} |
| |
const char CannotCreateDirectory::MSG[] = "cannot create directory: "; |
CIMValueInvalidTypeException::CIMValueInvalidTypeException() |
|
: Exception("invalid CIMValue type") |
|
{ |
|
} |
| |
const char NoSuchNameSpace::MSG[] = "no such namespace: "; |
DynamicCastFailedException::DynamicCastFailedException() |
|
: Exception("dynamic cast failed") |
|
{ |
|
} |
| |
const char CannotOpenFile::MSG[] = "cannot open file: "; |
InvalidDateTimeFormatException::InvalidDateTimeFormatException() |
|
: Exception("invalid datetime format") |
|
{ |
|
} |
| |
const char NotImplemented::MSG[] = "not implemented: "; |
IncompatibleTypesException::IncompatibleTypesException() |
|
: Exception("incompatible types") |
|
{ |
|
} |
| |
const char FailedToRemoveDirectory::MSG[] = "failed to remove directory: "; |
MalformedObjectNameException::MalformedObjectNameException( |
|
const String& objectName) |
|
: Exception("malformed object name: " + objectName) |
|
{ |
|
} |
| |
const char FailedToRemoveFile::MSG[] = "failed to remove file: "; |
BindFailedException::BindFailedException(const String& message) |
|
: Exception("Bind failed: " + message) |
|
{ |
|
} |
| |
const char StackUnderflow::MSG[] = "stack overflow"; |
InvalidLocatorException::InvalidLocatorException(const String& locator) |
|
: Exception("Invalid locator: " + locator) |
|
{ |
|
} |
| |
const char BadFormat::MSG[] = "bad format passed to Formatter::format()"; |
CannotCreateSocketException::CannotCreateSocketException() |
|
: Exception("Cannot create socket") |
|
{ |
|
} |
| |
const char BadDateTimeFormat::MSG[] = "bad datetime format"; |
CannotConnectException::CannotConnectException(const String& locator) |
|
: Exception("Cannot connect to: " + locator) |
|
{ |
|
} |
| |
const char IncompatibleTypes::MSG[] = "incompatible types"; |
UnexpectedFailureException::UnexpectedFailureException() |
|
: Exception("Unexpected failure") |
|
{ |
|
} |
| |
const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string"; |
AlreadyConnectedException::AlreadyConnectedException() |
|
: Exception("already connected") |
|
{ |
|
} |
| |
const char IllformedObjectName::MSG[] = "illformed object name: "; |
NotConnectedException::NotConnectedException() |
|
: Exception("not connected") |
|
{ |
|
} |
| |
const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: "; |
ConnectionTimeoutException::ConnectionTimeoutException() |
|
: Exception("connection timed out") |
|
{ |
|
} |
| |
const char DynamicLookupFailed::MSG[] = |
SSLException::SSLException(const String& message) |
"lookup of symbol in dynamic library failed: "; |
: Exception("SSL Exception: " + message) |
|
{ |
|
} |
| |
const char CannotOpenDirectory::MSG[] = "cannot open directory: "; |
|
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
static const char* _cimMessages[] = |
CIMException::CIMException( |
|
CIMStatusCode code, |
|
const String& message) |
|
: |
|
Exception(message) |
{ | { |
"SUCCESS: successful", |
_rep = new CIMExceptionRep(); |
|
_rep->code = code; |
"FAILED: A general error occurred that is not covered by a more specific " |
_rep->file = ""; |
"error code", |
_rep->line = 0; |
|
} |
"ACCESS_DENIED: Access to a CIM resource was not available to the client", |
|
|
|
"INVALID_NAMESPACE: The target namespace does not exist", |
|
|
|
"INVALID_PARAMETER: One or more parameter values passed to the method " |
|
"were invalid", |
|
|
|
"INVALID_CLASS: The specified class does not exist", |
|
|
|
"NOT_FOUND: The requested object could not be found", |
|
|
|
"NOT_SUPPORTED: The requested operation is not supported", |
|
|
|
"CLASS_HAS_CHILDREN: Operation cannot be carried out on this class since " |
|
"it has subclasses", |
|
|
|
"CLASS_HAS_INSTANCES: Operation cannot be carried out on this class since " |
|
"it has instances", |
|
|
|
"INVALID_SUPERCLASS: Operation cannot be carried out since the specified " |
|
"superclass does not exist", |
|
|
|
"ALREADY_EXISTS: Operation cannot be carried out because an object already " |
|
"exists", |
|
|
|
"NO_SUCH_PROPERTY: The specified property does not exist", |
|
|
|
"TYPE_MISMATCH: The value supplied is incompatible with the type", |
|
|
|
"QUERY_LANGUAGE_NOT_SUPPORTED: The query language is not recognized or " |
|
"supported", |
|
|
|
"INVALID_QUERY: The query is not valid for the specified query language", |
|
|
|
"METHOD_NOT_AVAILABLE: The extrinsic method could not be executed", |
|
|
|
"METHOD_NOT_FOUND: The specified extrinsic method does not exist" |
|
}; |
|
| |
static String _makeCIMExceptionMessage( |
CIMException::CIMException(const CIMException & cimException) |
CIMException::Code code, |
: Exception(cimException.getMessage()) |
const char* file, |
|
Uint32 line, |
|
const String& extraMessage) |
|
{ | { |
String tmp = file; |
_rep = new CIMExceptionRep(); |
tmp.append("("); |
_rep->code = cimException._rep->code; |
char buffer[32]; |
_rep->file = cimException._rep->file; |
sprintf(buffer, "%d", line); |
_rep->line = cimException._rep->line; |
tmp.append(buffer); |
|
tmp.append("): "); |
|
|
|
tmp.append(_cimMessages[Uint32(code)]); |
|
tmp.append(": \""); |
|
tmp.append(extraMessage); |
|
tmp.append("\""); |
|
return tmp; |
|
} | } |
| |
CIMException::CIMException( |
CIMException& CIMException::operator=(const CIMException & cimException) |
CIMException::Code code, |
|
const char* file, |
|
Uint32 line, |
|
const String& extraMessage) |
|
: Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)), |
|
_code(code) |
|
{ | { |
|
_message = cimException._message; |
|
_rep->code = cimException._rep->code; |
|
_rep->file = cimException._rep->file; |
|
_rep->line = cimException._rep->line; |
|
return *this; |
} | } |
| |
const char* CIMException::codeToString(CIMException::Code code) |
CIMException::~CIMException() |
{ | { |
return _cimMessages[Uint32(code)]; |
delete _rep; |
} | } |
| |
void ThrowUnitializedHandle() |
CIMStatusCode CIMException::getCode() const |
{ | { |
throw UnitializedHandle(); |
return _rep->code; |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |