(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.87

version 1.7, 2001/02/16 02:06:06 version 1.87, 2014/08/27 23:10:08
Line 1 
Line 1 
 //BEGIN_LICENSE  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM  // Licensed to The Open Group (TOG) under one or more contributor license
   // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   // this work for additional information regarding copyright ownership.
   // Each contributor licenses this file to you under the OpenPegasus Open
   // Source License; you may not use this file except in compliance with the
   // License.
 // //
 // 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 of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
Line 9 
Line 14 
 // and/or sell copies of the Software, and to permit persons to whom the // and/or sell copies of the Software, and to permit persons to whom the
 // Software is furnished to do so, subject to the following conditions: // Software is 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
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  // in all copies or substantial portions of the Software.
 // 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  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 //BEGIN_HISTORY  // 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:  //////////////////////////////////////////////////////////////////////////
 // //
 // $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.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 reference";  
   
 const char IllegalName::MSG[] = "illegal CIM name";  
   
 const char NoSuchSuperClass::MSG[] = "no such super class: ";  
   
 const char NoSuchClass::MSG[] = "no such class: ";  
   
 const char InvalidPropertyOverride::MSG[] = "invalid property override: ";  
  
 const char InvalidMethodOverride::MSG[] = "invalid method override: ";  const ContentLanguageList& Exception::getContentLanguages() const
   {
       return _rep->contentLanguages;
   }
  
 const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";  void Exception::setContentLanguages(const ContentLanguageList& langs)
   {
       _rep->contentLanguages = langs;
   }
  
 const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";  IndexOutOfBoundsException::IndexOutOfBoundsException()
       : Exception(MessageLoaderParms(
             "Common.Exception.INDEX_OUT_OF_BOUNDS_EXCEPTION",
             "index out of bounds"))
   {
   }
  
 const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";  AlreadyExistsException::AlreadyExistsException(const String& message)
       : Exception(MessageLoaderParms(
             "Common.Exception.ALREADY_EXISTS_EXCEPTION",
             "already exists: $0",
             message))
   {
   }
  
 const char BadQualifierType::MSG[] =  AlreadyExistsException::AlreadyExistsException(MessageLoaderParms& msgParms)
     "CIMType of qualifier different than its declaration: ";      : Exception(MessageLoaderParms(
             "Common.Exception.ALREADY_EXISTS_EXCEPTION",
             "already exists: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char NullType::MSG[] = "type is null";  InvalidNameException::InvalidNameException(const String& message)
       : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_NAME_EXCEPTION",
             "The CIM name is not valid: $0",
             message))
   {
   }
  
 const char AddedReferenceToClass::MSG[] =  InvalidNameException::InvalidNameException(MessageLoaderParms& msgParms)
     "attempted to add reference to a non-association class: ";      : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_NAME_EXCEPTION",
             "invalid CIM name: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char ClassAlreadyResolved::MSG[] =  InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
     "attempt to resolve a class that is already resolved: ";      : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_NAMESACE_NAME_EXCEPTION",
             "invalid CIM namespace name: $0",
             name))
   {
   }
  
 const char ClassNotResolved::MSG[] =  InvalidNamespaceNameException::InvalidNamespaceNameException(
     "class is not yet resolved: ";      MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_NAMESPACE_NAME_EXCEPTION",
             "invalid CIM namespace name: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char InstanceAlreadyResolved::MSG[] =  UninitializedObjectException::UninitializedObjectException()
     "attempted to resolve a instance that is already resolved";      : Exception(MessageLoaderParms(
             "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
             "uninitialized object"))
   {
   }
  
 const char InstantiatedAbstractClass::MSG[] =  TypeMismatchException::TypeMismatchException()
     "attempted to instantiated an abstract class";      : Exception(MessageLoaderParms(
             "Common.Exception.TYPE_MISMATCH_EXCEPTION",
             "type mismatch"))
   {
   }
  
 const char NoSuchProperty::MSG[] = "no such property: ";  TypeMismatchException::TypeMismatchException(const String& message)
       : Exception(MessageLoaderParms(
             "Common.Exception.TYPE_MISMATCH_EXCEPTION",
             "type mismatch: $0",message))
   {
  
 const char TruncatedCharacter::MSG[] =  }
     "truncated character during conversion from Char16 to char";  
  
 const char ExpectedReferenceValue::MSG[] =  TypeMismatchException::TypeMismatchException(MessageLoaderParms& msgParms)
     "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "      : Exception(MessageLoaderParms(
     "in this context";            "Common.Exception.TYPE_MISMATCH_EXCEPTION",
             "type mismatch: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char MissingReferenceClassName::MSG[] = "missing reference class name";  DynamicCastFailedException::DynamicCastFailedException()
       : Exception(MessageLoaderParms(
             "Common.Exception.DYNAMIC_CAST_FAILED_EXCEPTION",
             "dynamic cast failed"))
   {
   }
  
 const char IllegalTypeTag::MSG[] = "illegal type tag";  InvalidDateTimeFormatException::InvalidDateTimeFormatException()
       : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_DATETIME_FORMAT_EXCEPTION",
             "invalid datetime format"))
   {
   }
  
 const char TypeMismatch::MSG[] = "type mismatch";  MalformedObjectNameException::MalformedObjectNameException(
       const String& message)
       : Exception(MessageLoaderParms(
             "Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
             "malformed object name: $0",
             message))
   {
   }
  
 const char NoSuchFile::MSG[] = "no such file: ";  MalformedObjectNameException::MalformedObjectNameException(
       MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms(
             "Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
             "malformed object name: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char NoSuchDirectory::MSG[] = "no such directory: ";  BindFailedException::BindFailedException(const String& message)
       : Exception(MessageLoaderParms(
             "Common.Exception.BIND_FAILED_EXCEPTION",
             "Bind failed: $0",
             message))
   {
   }
  
 const char ChangeDirectoryFailed::MSG[] = "failed to change directory: ";  BindFailedException::BindFailedException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms(
             "Common.Exception.BIND_FAILED_EXCEPTION",
             "Bind failed: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char CannotCreateDirectory::MSG[] = "cannot create directory: ";  InvalidLocatorException::InvalidLocatorException(const String& message)
       : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_LOCATOR_EXCEPTION",
             "Invalid locator: $0",
             message))
   {
   }
  
 const char NoSuchNameSpace::MSG[] = "no such namespace: ";  InvalidLocatorException::InvalidLocatorException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_LOCATOR_EXCEPTION",
             "Invalid locator: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char CannotOpenFile::MSG[] = "cannot open file: ";  CannotCreateSocketException::CannotCreateSocketException()
       : Exception(MessageLoaderParms(
             "Common.Exception.CANNOT_CREATE_SOCKET_EXCEPTION",
             "Cannot create socket"))
   {
   }
  
 const char NotImplemented::MSG[] = "not implemented: ";  
  
 const char FailedToRemoveDirectory::MSG[] = "failed to remove directory: ";  CannotConnectException::CannotConnectException(const String& message)//???
       : Exception(message)
   {
   }
  
 const char FailedToRemoveFile::MSG[] = "failed to remove file: ";  
  
 const char StackUnderflow::MSG[] = "stack overflow";  CannotConnectException::CannotConnectException(MessageLoaderParms& msgParms)
       : Exception(msgParms)
   {
   }
  
 const char BadFormat::MSG[] = "bad format passed to Formatter::format()";  AlreadyConnectedException::AlreadyConnectedException()
       : Exception(MessageLoaderParms(
             "Common.Exception.ALREADY_CONNECTED_EXCEPTION",
             "already connected"))
   {
   }
  
 const char BadDateTimeFormat::MSG[] = "bad datetime format";  
  
 const char IncompatibleTypes::MSG[] = "incompatible types";  NotConnectedException::NotConnectedException()
       : Exception(MessageLoaderParms(
             "Common.Exception.NOT_CONNECTED_EXCEPTION",
             "not connected"))
   {
   }
  
 const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";  ConnectionTimeoutException::ConnectionTimeoutException()
       : Exception(MessageLoaderParms(
             "Common.Exception.CONNECTION_TIMEOUT_EXCEPTION",
             "connection timed out"))
   {
   }
   // EXP_PULL_BEGIN
   InvalidEnumerationContextException::InvalidEnumerationContextException()
       : Exception(MessageLoaderParms(
             "Common.Exception.INVALID_ENUMERATION_CONTEXT_EXCEPTION",
             "Invalid Enumeration Context, uninitilialized"))
   {
   }
   // EXP_PULL_END
  
 const char BadInstanceName::MSG[] = "bad instance name: ";  SSLException::SSLException(const String& message)
       : Exception(MessageLoaderParms(
             "Common.Exception.SSL_EXCEPTION",
             "SSL Exception: $0" ,
             message))
   {
   }
  
 const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";  SSLException::SSLException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms(
             "Common.Exception.SSL_EXCEPTION",
             "SSL Exception: $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 const char DynamicLookupFailed::MSG[] =  DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
     "lookup of symbol in dynamic library failed: ";      : Exception(MessageLoaderParms(
             "Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
             "DateTime is out of range : $0" ,
             message))
   {
   }
  
 const char CannotOpenDirectory::MSG[] = "cannot open directory: ";  DateTimeOutOfRangeException::DateTimeOutOfRangeException(
       MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms(
             "Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
             "DateTime is out of range : $0",
             MessageLoader::getMessage(msgParms)))
   {
   }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // //
 // CimException  // CIMException
 // //
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
  
 static char* _cimMessages[] =  // 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()
 { {
     "successful",      CIMExceptionRep * tmp = new CIMExceptionRep ();
       tmp->message = message;
     "A general error occurred that is not covered by a more specific "      tmp->code = code;
     "error code.",      tmp->file = "";
       tmp->line = 0;
     "Access to a CIM resource was not available to the client.",      tmp->contentLanguages.clear();
       tmp->cimMessage = String::EMPTY;
     "The target namespace does not exist.",      _rep = tmp;
   }
     "One or more parameter values passed to the method were invalid.",  
   
     "The specified class does not exist.",  
   
     "The requested object could not be found.",  
   
     "The requested operation is not supported.",  
   
     "Operation cannot be carried out on this class since it has subclasses.",  
  
     "Operation cannot be carried out on this class since it has instances.",  
  
     "Operation cannot be carried out since the specified "  // l10n - note - use this when you have an exception
     "superClass does not exist.",  // 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;
   }
  
     "Operation cannot be carried out because an object already exists.",  // 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,
       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 property does not exist.",  CIMException::CIMException(
       CIMStatusCode code,
       const MessageLoaderParms& msgParms,
       const CIMInstance& instance)
       : 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;
   }
  
     "The value supplied is incompatible with the type.",  CIMException::CIMException(
       CIMStatusCode code,
       const MessageLoaderParms& msgParms,
       const Array<CIMInstance>& instances)
       : 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.appendArray(instances);
       tmp->code = code;
       tmp->file = "";
       tmp->line = 0;
       _rep = tmp;
   }
  
     "The query language is not recognized or supported.",  CIMException::CIMException(const CIMException & cimException)
       : Exception()
   {
       _rep = new CIMExceptionRep(
           *reinterpret_cast<CIMExceptionRep*>(cimException._rep));
   }
  
     "The query is not valid for the specified query language.",  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;
   }
  
     "The extrinsic method could not be executed.",  CIMException::~CIMException()
   {
   }
  
     "The specified extrinsic method does not exist."  Uint32 CIMException::getErrorCount() const
 };  {
       return reinterpret_cast<CIMExceptionRep*>(_rep)->errors.size();
   }
   /**************
   CIMInstance CIMException::getError(Uint32 index)
   {
       return reinterpret_cast<CIMExceptionRep*>(_rep)->errors[index];
   }
   ***************/
  
 CimException::CimException(CimException::Code code)  CIMConstInstance CIMException::getError(Uint32 index) const
     : Exception(_cimMessages[Uint32(code)]), _code(code)  
 { {
       return reinterpret_cast<CIMExceptionRep*>(_rep)->errors[index];
   }
  
   void CIMException::addError(const CIMInstance& instance)
   {
       reinterpret_cast<CIMExceptionRep*>(_rep)->errors.append(instance);
 } }
  
 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.87

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2