(file) Return to Exception.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Exception.cpp between version 1.7 and 1.63.6.4

version 1.7, 2001/02/16 02:06:06 version 1.63.6.4, 2003/08/14 11:55:42
Line 1 
Line 1 
 //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, 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)
   //              Sushma Fernandes , Hewlett-Packard Company
   //                (sushma_fernandes@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 <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 = ContentLanguages::EMPTY;  // l10n
   }
  
   Exception::Exception(const Exception& exception)
   {
       _rep = new ExceptionRep();
       _rep->message = exception._rep->message;
       _rep->contentLanguages = exception._rep->contentLanguages;    // l10n
 } }
  
 Exception::Exception(const char* message) : _message(message)  // l10n
   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()
   {
 } }
  
 Exception::~Exception() Exception::~Exception()
 { {
       delete _rep;
 } }
  
 AssertionFailureException::AssertionFailureException(  const String& Exception::getMessage() const
     const char* file,  
     size_t line,  
     const String& message) : Exception(String())  
 { {
     char lineStr[32];      return _rep->message;
     sprintf(lineStr, "%d", line);  
   
     _message = file;  
     _message.append("(");  
     _message.append(lineStr);  
     _message.append("): ");  
     _message.append(message);  
 } }
  
 const char OutOfBounds::MSG[] = "out of bounds";  // l10n
   const ContentLanguages& Exception::getContentLanguages() const
 const char AlreadyExists::MSG[] = "already exists: ";  {
           return _rep->contentLanguages;
 const char NullPointer::MSG[] = "null pointer";  }
   
 const char UnitializedHandle::MSG[] = "unitialized reference";  
   
 const char IllegalName::MSG[] = "illegal CIM name";  
  
 const char NoSuchSuperClass::MSG[] = "no such super class: ";  // l10n
   void Exception::setContentLanguages(const ContentLanguages& langs)
   {
           _rep->contentLanguages = langs;
   }
  
 const char NoSuchClass::MSG[] = "no such class: ";  /*
   IndexOutOfBoundsException::IndexOutOfBoundsException()
       : Exception("index out of bounds")
   {
   }
   */
  
 const char InvalidPropertyOverride::MSG[] = "invalid property override: ";  IndexOutOfBoundsException::IndexOutOfBoundsException()
       : Exception(MessageLoaderParms("Common.Exception.IndexOutOfBoundsException","index out of bounds"))
   {
   }
  
 const char InvalidMethodOverride::MSG[] = "invalid method override: ";  /*
   AlreadyExistsException::AlreadyExistsException(const String& message)
       : Exception("already exists: " + message)
   {
   }
   */
  
 const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";  AlreadyExistsException::AlreadyExistsException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.AlreadyExistsException",
                                                                   "already exists: $0",
                                                                    message))
   {
   }
  
 const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";  AlreadyExistsException::AlreadyExistsException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.AlreadyExistsException",
                                                                   "already exists: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";  /*
   InvalidNameException::InvalidNameException(const String& name)
       : Exception("invalid CIM name: " + name)
   {
   }
   */
  
 const char BadQualifierType::MSG[] =  InvalidNameException::InvalidNameException(const String& message)
     "CIMType of qualifier different than its declaration: ";      : Exception(MessageLoaderParms("Common.Exception.InvalidNameException",
                                                                   "invalid CIM name: $0",
                                                                    message))
   {
   }
  
 const char NullType::MSG[] = "type is null";  InvalidNameException::InvalidNameException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.InvalidNameException",
                                                                   "invalid CIM name: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char AddedReferenceToClass::MSG[] =  /*
     "attempted to add reference to a non-association class: ";  InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
       : Exception("invalid CIM namespace name: " + name)
   {
   }
   */
  
 const char ClassAlreadyResolved::MSG[] =  
     "attempt to resolve a class that is already resolved: ";  
  
 const char ClassNotResolved::MSG[] =  InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
     "class is not yet resolved: ";      : Exception(MessageLoaderParms("Common.Exception.InvalidNamespaceNameException",
                                                                   "invalid CIM namespace name: $0",
                                                                    name))
   {
   }
  
 const char InstanceAlreadyResolved::MSG[] =  InvalidNamespaceNameException::InvalidNamespaceNameException(MessageLoaderParms& msgParms)
     "attempted to resolve a instance that is already resolved";      : Exception(MessageLoaderParms("Common.Exception.InvalidNamespaceNameException",
                                                                   "invalid CIM namespace name: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char InstantiatedAbstractClass::MSG[] =  /*
     "attempted to instantiated an abstract class";  
  
 const char NoSuchProperty::MSG[] = "no such property: ";  UninitializedObjectException::UninitializedObjectException()
       : Exception("uninitialized object")
   {
   }
   */
  
 const char TruncatedCharacter::MSG[] =  UninitializedObjectException::UninitializedObjectException()
     "truncated character during conversion from Char16 to char";      : Exception(MessageLoaderParms("Common.Exception.UninitializedObjectException",
                                                                   "uninitialized object"))
   {
   }
  
 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";  /*
   TypeMismatchException::TypeMismatchException()
       : Exception("type mismatch")
   {
   }
   */
  
 const char IllegalTypeTag::MSG[] = "illegal type tag";  TypeMismatchException::TypeMismatchException()
       : Exception(MessageLoaderParms("Common.Exception.TypeMismatchException",
                                                                   "type mismatch"))
   {
   }
  
 const char TypeMismatch::MSG[] = "type mismatch";  /*
   DynamicCastFailedException::DynamicCastFailedException()
       : Exception("dynamic cast failed")
   {
   }
   */
  
 const char NoSuchFile::MSG[] = "no such file: ";  DynamicCastFailedException::DynamicCastFailedException()
       : Exception(MessageLoaderParms("Common.Exception.DynamicCastFailedException",
                                                                   "dynamic cast failed"))
   {
   }
  
 const char NoSuchDirectory::MSG[] = "no such directory: ";  /*
   InvalidDateTimeFormatException::InvalidDateTimeFormatException()
       : Exception("invalid datetime format")
   {
   }
   */
  
 const char ChangeDirectoryFailed::MSG[] = "failed to change directory: ";  InvalidDateTimeFormatException::InvalidDateTimeFormatException()
       : Exception(MessageLoaderParms("Common.Exception.InvalidDateTimeFormatException",
                                                                   "invalid datetime format"))
   {
   }
  
 const char CannotCreateDirectory::MSG[] = "cannot create directory: ";  /*
   MalformedObjectNameException::MalformedObjectNameException(
       const String& objectName)
       : Exception("malformed object name: " + objectName)
   {
   }
   */
  
 const char NoSuchNameSpace::MSG[] = "no such namespace: ";  MalformedObjectNameException::MalformedObjectNameException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.MalformedObjectNameException",
                                                                   "malformed object name: $0",
                                                                    message))
   {
   }
  
 const char CannotOpenFile::MSG[] = "cannot open file: ";  MalformedObjectNameException::MalformedObjectNameException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.MalformedObjectNameException",
                                                                   "malformed object name: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char NotImplemented::MSG[] = "not implemented: ";  
  
 const char FailedToRemoveDirectory::MSG[] = "failed to remove directory: ";  /*
   BindFailedException::BindFailedException(const String& message)
       : Exception("Bind failed: " + message)
   {
   }
   */
  
 const char FailedToRemoveFile::MSG[] = "failed to remove file: ";  BindFailedException::BindFailedException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.BindFailedException",
                                                                   "Bind failed: $0",
                                                                    message))
   {
   }
  
 const char StackUnderflow::MSG[] = "stack overflow";  BindFailedException::BindFailedException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.BindFailedException",
                                                                   "Bind failed: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char BadFormat::MSG[] = "bad format passed to Formatter::format()";  /*
   InvalidLocatorException::InvalidLocatorException(const String& locator)
       : Exception("Invalid locator: " + locator)
   {
   }
   */
  
 const char BadDateTimeFormat::MSG[] = "bad datetime format";  InvalidLocatorException::InvalidLocatorException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.InvalidLocatorException",
                                                                   "Invalid locator: $0",
                                                                    message))
   {
   }
  
 const char IncompatibleTypes::MSG[] = "incompatible types";  InvalidLocatorException::InvalidLocatorException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.InvalidLocatorException",
                                                                   "Invalid locator: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";  /*
  
 const char BadInstanceName::MSG[] = "bad instance name: ";  CannotCreateSocketException::CannotCreateSocketException()
       : Exception("Cannot create socket")
   {
   }
   */
  
 const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";  CannotCreateSocketException::CannotCreateSocketException()
       : Exception(MessageLoaderParms("Common.Exception.CannotCreateSocketException",
                                                                   "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)
   {
   }
  
 ////////////////////////////////////////////////////////////////////////////////  
 //  
 // CimException  
 //  
 ////////////////////////////////////////////////////////////////////////////////  
  
 static char* _cimMessages[] =  CannotConnectException::CannotConnectException(MessageLoaderParms& msgParms)
       : Exception(msgParms)
 { {
     "successful",  }
  
     "A general error occurred that is not covered by a more specific "  /*
     "error code.",  AlreadyConnectedException::AlreadyConnectedException()
       : Exception("already connected")
   {
   }
   */
  
     "Access to a CIM resource was not available to the client.",  AlreadyConnectedException::AlreadyConnectedException()
       : Exception(MessageLoaderParms("Common.Exception.AlreadyConnectedException",
                                                                   "already connected"))
   {
   }
  
     "The target namespace does not exist.",  /*
   NotConnectedException::NotConnectedException()
       : Exception("not connected")
   {
   }
   */
  
     "One or more parameter values passed to the method were invalid.",  NotConnectedException::NotConnectedException()
       : Exception(MessageLoaderParms("Common.Exception.NotConnectedException",
                                                                   "not connected"))
   {
   }
  
     "The specified class does not exist.",  /*
   ConnectionTimeoutException::ConnectionTimeoutException()
       : Exception("connection timed out")
   {
   }
   */
  
     "The requested object could not be found.",  ConnectionTimeoutException::ConnectionTimeoutException()
       : Exception(MessageLoaderParms("Common.Exception.ConnectionTimeoutException",
                                                                   "connection timed out"))
   {
   }
  
     "The requested operation is not supported.",  /*
   SSLException::SSLException(const String& message)
       : Exception("SSL Exception: " + message)
   {
   }
   */
  
     "Operation cannot be carried out on this class since it has subclasses.",  SSLException::SSLException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.SSLException",
                                                                   "SSL Exception: $0" ,
                                                                    message))
   {
   }
  
     "Operation cannot be carried out on this class since it has instances.",  SSLException::SSLException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.SSLException",
                                                                   "SSL Exception: " ))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
     "Operation cannot be carried out since the specified "  /*
     "superClass does not exist.",  DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
       : Exception("DateTime is out of range : " + message)
   {
   }
   */
  
     "Operation cannot be carried out because an object already exists.",  DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.DateTimeOutOfRangeException",
                                                                   "DateTime is out of range : $0" ,
                                                                    message))
   {
   }
  
     "The specified property does not exist.",  DateTimeOutOfRangeException::DateTimeOutOfRangeException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.DateTimeOutOfRangeException",
                                                                   "DateTime is out of range : " ))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
     "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.",  // 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 = ContentLanguages::EMPTY;
       tmp->cimMessage = String::EMPTY;
       _rep = tmp;
   }
  
     "The extrinsic method could not be executed.",  // l10n - note use this when you have an exception with a translated
   // detail message
   // l10n
   CIMException::CIMException(
       CIMStatusCode code,
       const MessageLoaderParms& msgParms)
       : 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->code = code;
       tmp->file = "";
       tmp->line = 0;
       _rep = tmp;
   }
  
     "The specified extrinsic method does not exist."  CIMException::CIMException(const CIMException & cimException)
 };      : Exception()
   {
       CIMExceptionRep * tmp = new CIMExceptionRep ();
       CIMExceptionRep * rep;
       rep = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
       tmp->message = rep->message;
       tmp->contentLanguages = rep->contentLanguages;  // l10n
       tmp->cimMessage = rep->cimMessage;  // l10n
       tmp->code = rep->code;
       tmp->file = rep->file;
       tmp->line = rep->line;
       _rep = tmp;
   }
  
 CimException::CimException(CimException::Code code)  CIMException& CIMException::operator=(const CIMException & cimException)
     : Exception(_cimMessages[Uint32(code)]), _code(code)  
 { {
       CIMExceptionRep* left;
       CIMExceptionRep* right;
       left = reinterpret_cast<CIMExceptionRep*>(this->_rep);
       right = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
       left->message = right->message;
       left->contentLanguages = right->contentLanguages;  // l10n
       left->cimMessage = right->cimMessage;  // l10n
       left->code = right->code;
       left->file = right->file;
       left->line = right->line;
       return *this;
   }
  
   CIMException::~CIMException()
   {
 } }
  
 const char* CimException::codeToString(CimException::Code code)  CIMStatusCode CIMException::getCode() const
 { {
     return _cimMessages[Uint32(code)];      CIMExceptionRep* rep;
       rep = reinterpret_cast<CIMExceptionRep*>(_rep);
       return rep->code;
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.7  
changed lines
  Added in v.1.63.6.4

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2