version 1.7, 2001/02/16 02:06:06
|
version 1.48, 2002/08/14 17:41:16
|
|
|
//BEGIN_LICENSE |
//%///////////////////////////////////////////////////////////////////////////// |
// | // |
// 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 ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
|
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
|
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
|
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
// 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) |
|
// |
|
// Modified By: Nag Boranna (nagaraja_boranna@hp.com) |
|
// |
|
// Modified By: Jenny Yu (jenny_yu@am.exch.hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
// | // |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
//%///////////////////////////////////////////////////////////////////////////// |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
// LIABILITY, WHETHER IN AN 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. |
|
// |
|
//END_LICENSE |
|
//BEGIN_HISTORY |
|
// |
|
// Author: |
|
// |
|
// $Log$ |
|
// Revision 1.7 2001/02/16 02:06:06 mike |
|
// Renamed many classes and headers. |
|
// |
|
// Revision 1.6 2001/02/11 05:42:33 mike |
|
// new |
|
// |
|
// Revision 1.5 2001/01/29 02:23:44 mike |
|
// Added support for GetInstance operation |
|
// |
|
// Revision 1.4 2001/01/28 04:11:03 mike |
|
// fixed qualifier resolution |
|
// |
|
// Revision 1.3 2001/01/23 01:25:35 mike |
|
// Reworked resolve scheme. |
|
// |
|
// Revision 1.2 2001/01/22 00:45:47 mike |
|
// more work on resolve scheme |
|
// |
|
// Revision 1.1.1.1 2001/01/14 19:51:33 mike |
|
// Pegasus import |
|
// |
|
// |
|
//END_HISTORY |
|
| |
#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 reference"; |
const char UninitializedHandle::MSG[] = "uninitialized handle"; |
| |
const char IllegalName::MSG[] = "illegal CIM name"; |
const char UninitializedObject::MSG[] = "uninitialized object"; |
| |
const char NoSuchSuperClass::MSG[] = "no such super class: "; |
const char IllegalName::MSG[] = "illegal CIM name"; |
| |
const char NoSuchClass::MSG[] = "no such class: "; |
const char IllegalNamespaceName::MSG[] = "illegal CIM namespace name"; |
| |
const char InvalidPropertyOverride::MSG[] = "invalid property override: "; | const char InvalidPropertyOverride::MSG[] = "invalid property override: "; |
| |
|
|
| |
const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: "; | const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: "; |
| |
|
const char InvalidScope::MSG[] = "invalid scope value: "; |
|
|
|
const char InvalidFlavor::MSG[] = "invalid flavor value: "; |
|
|
const char BadQualifierOverride::MSG[] = "qualifier not overridable: "; | const char BadQualifierOverride::MSG[] = "qualifier not overridable: "; |
| |
const char BadQualifierType::MSG[] = | const char BadQualifierType::MSG[] = |
|
|
"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 CannotBindToAddress::MSG[] = "cannot bind to address: "; |
|
|
const char NoSuchDirectory::MSG[] = "no such directory: "; | const char NoSuchDirectory::MSG[] = "no such directory: "; |
| |
const char ChangeDirectoryFailed::MSG[] = "failed to change directory: "; |
const char ChangeDirectoryFailed::MSG[] = "cannot change directory: "; |
| |
const char CannotCreateDirectory::MSG[] = "cannot create directory: "; | const char CannotCreateDirectory::MSG[] = "cannot create directory: "; |
| |
|
|
| |
const char NotImplemented::MSG[] = "not implemented: "; | const char NotImplemented::MSG[] = "not implemented: "; |
| |
const char FailedToRemoveDirectory::MSG[] = "failed to remove directory: "; |
const char CannotRemoveDirectory::MSG[] = "cannot remove directory: "; |
|
|
|
const char CannotRemoveFile::MSG[] = "cannot remove file: "; |
| |
const char FailedToRemoveFile::MSG[] = "failed to remove file: "; |
const char CannotRenameFile::MSG[] = "cannot rename file: "; |
| |
const char StackUnderflow::MSG[] = "stack overflow"; |
const char StackUnderflow::MSG[] = "stack underflow"; |
|
|
|
const char StackOverflow::MSG[] = "stack overflow"; |
|
|
|
const char QueueUnderflow::MSG[] = "queue Underflow"; |
| |
const char BadFormat::MSG[] = "bad format passed to Formatter::format()"; | const char BadFormat::MSG[] = "bad format passed to Formatter::format()"; |
| |
|
|
| |
const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string"; | const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string"; |
| |
const char BadInstanceName::MSG[] = "bad instance name: "; |
const char IllformedObjectName::MSG[] = "illformed object name: "; |
| |
const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: "; | const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: "; |
| |
|
|
| |
const char CannotOpenDirectory::MSG[] = "cannot open directory: "; | const char CannotOpenDirectory::MSG[] = "cannot open directory: "; |
| |
//////////////////////////////////////////////////////////////////////////////// |
const char CorruptFile::MSG[] = "corrupt file: "; |
// |
|
// CimException |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
| |
static char* _cimMessages[] = |
const char BindFailed::MSG[] = "Bind failed: "; |
{ |
|
"successful", |
|
| |
"A general error occurred that is not covered by a more specific " |
const char InvalidLocator::MSG[] = "Invalid locator: "; |
"error code.", |
|
| |
"Access to a CIM resource was not available to the client.", |
const char CannotCreateSocket::MSG[] = "Cannot create socket"; |
| |
"The target namespace does not exist.", |
const char CannotConnect::MSG[] = "Cannot connect to: "; |
| |
"One or more parameter values passed to the method were invalid.", |
const char UnexpectedFailure::MSG[] = "Unexpected failure"; |
| |
"The specified class does not exist.", |
const char AlreadyConnected::MSG[] = "already connected"; |
| |
"The requested object could not be found.", |
const char NotConnected::MSG[] = "not connected"; |
| |
"The requested operation is not supported.", |
const char TimedOut::MSG[] = "timed out"; |
| |
"Operation cannot be carried out on this class since it has subclasses.", |
const char ParseError::MSG[] = "parse error: "; |
| |
"Operation cannot be carried out on this class since it has instances.", |
const char MissingNullTerminator::MSG[] = "missing null terminator: "; |
| |
"Operation cannot be carried out since the specified " |
const char SSL_Exception::MSG[] = "SSL Exception "; |
"superClass does not exist.", |
|
| |
"Operation cannot be carried out because an object already exists.", |
const char InvalidAuthHeader::MSG[] = "Invalid Authorization header"; |
| |
"The specified property does not exist.", |
const char UnauthorizedAccess::MSG[] = "Unauthorized access"; |
| |
"The value supplied is incompatible with the type.", |
|
| |
"The query language is not recognized or supported.", |
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// CIMException |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
| |
"The query is not valid for the specified query language.", |
// |
|
// 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; |
|
} |
| |
"The extrinsic method could not be executed.", |
// |
|
// Creates a description with source file name and line number. |
|
// |
|
static String _makeCIMExceptionDescription( |
|
CIMStatusCode code, |
|
const String& message, |
|
const char* file, |
|
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; |
|
} |
| |
"The specified extrinsic method does not exist." |
CIMException::CIMException( |
}; |
CIMStatusCode code, |
|
const String& message, |
|
const char* file, |
|
Uint32 line) |
|
: |
|
Exception(message), |
|
_code(code), |
|
_file(file), |
|
_line(line) |
|
{ |
|
|
|
} |
|
|
|
// |
|
// Returns a description string fit for human consumption |
|
// |
|
String CIMException::getDescription() const |
|
{ |
|
#ifdef DEBUG_CIMEXCEPTION |
|
return getTraceDescription(); |
|
#else |
|
return _makeCIMExceptionDescription(_code, getMessage()); |
|
#endif |
|
} |
| |
CimException::CimException(CimException::Code code) |
// |
: Exception(_cimMessages[Uint32(code)]), _code(code) |
// Returns a description string with filename and line number information |
|
// specifically for tracing. |
|
// |
|
String CIMException::getTraceDescription() const |
{ | { |
|
String traceDescription = |
|
_makeCIMExceptionDescription(_code, getMessage(), _file, _line); |
| |
|
return traceDescription; |
|
} |
|
|
|
void ThrowUninitializedHandle() |
|
{ |
|
throw UninitializedHandle(); |
} | } |
| |
const char* CimException::codeToString(CimException::Code code) |
void ThrowUninitializedObject() |
{ | { |
return _cimMessages[Uint32(code)]; |
throw UninitializedObject(); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |