(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.42 and 1.71

version 1.42, 2002/06/01 00:56:31 version 1.71, 2004/06/29 11:42:44
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2003////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // 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.
 // //
 // 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
Line 23 
Line 25 
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By: Nag Boranna (nagaraja_boranna@hp.com)  // Modified By: Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
 //  //              Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
 // Modified By: Jenny Yu (jenny_yu@am.exch.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)
   //              Amit K Arora, IBM (amita@in.ibm.com) for bug# 1593
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <cstdio> #include <cstdio>
 #include "Exception.h" #include "Exception.h"
   #include <Pegasus/Common/ExceptionRep.h>
   #include <Pegasus/Common/CIMExceptionRep.h>
 #include "Tracer.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()
   {
       _rep = NULL;
 } }
  
 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, "%u", line);  
   
     _message = file;  
     _message.append("(");  
     _message.append(lineStr);  
     _message.append("): ");  
     _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";  // l10n
   const ContentLanguages& Exception::getContentLanguages() const
 const char AlreadyExists::MSG[] = "already exists: ";  {
           return _rep->contentLanguages;
 const char NullPointer::MSG[] = "null pointer";  }
   
 const char UninitializedHandle::MSG[] = "uninitialized 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[] =  // l10n
     "attempted to add reference to a non-association class: ";  void Exception::setContentLanguages(const ContentLanguages& langs)
   {
           _rep->contentLanguages = langs;
   }
  
 const char ClassAlreadyResolved::MSG[] =  /*
     "attempt to resolve a class that is already resolved: ";  IndexOutOfBoundsException::IndexOutOfBoundsException()
       : Exception("index out of bounds")
   {
   }
   */
  
 const char ClassNotResolved::MSG[] =  IndexOutOfBoundsException::IndexOutOfBoundsException()
     "class is not yet resolved: ";      : Exception(MessageLoaderParms("Common.Exception.INDEX_OUT_OF_BOUNDS_EXCEPTION","index out of bounds"))
   {
   }
  
 const char InstanceAlreadyResolved::MSG[] =  /*
     "attempted to resolve a instance that is already resolved";  AlreadyExistsException::AlreadyExistsException(const String& message)
       : Exception("already exists: " + message)
   {
   }
   */
  
 const char InstantiatedAbstractClass::MSG[] =  AlreadyExistsException::AlreadyExistsException(const String& message)
     "attempted to instantiate an abstract class ";      : Exception(MessageLoaderParms("Common.Exception.ALREADY_EXISTS_EXCEPTION",
                                                                   "already exists: $0",
                                                                    message))
   {
   }
  
 const char NoSuchProperty::MSG[] = "no such property: ";  AlreadyExistsException::AlreadyExistsException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.ALREADY_EXISTS_EXCEPTION",
                                                                   "already exists: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char TruncatedCharacter::MSG[] =  /*
     "truncated character during conversion from Char16 to char";  InvalidNameException::InvalidNameException(const String& name)
       : Exception("invalid CIM name: " + name)
   {
   }
   */
  
 const char ExpectedReferenceValue::MSG[] =  InvalidNameException::InvalidNameException(const String& message)
     "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "      : Exception(MessageLoaderParms("Common.Exception.INVALID_NAME_EXCEPTION",
     "in this context";                                                                  "invalid CIM name: $0",
                                                                    message))
   {
   }
  
 const char MissingReferenceClassName::MSG[] = "missing reference class name";  InvalidNameException::InvalidNameException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.INVALID_NAME_EXCEPTION",
                                                                   "invalid CIM name: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char IllegalTypeTag::MSG[] = "illegal type tag";  /*
   InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
       : Exception("invalid CIM namespace name: " + name)
   {
   }
   */
  
 const char TypeMismatch::MSG[] = "type mismatch";  
  
 const char CIMValueIsNull::MSG[] = "null CIMValue accessed";  InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
       : Exception(MessageLoaderParms("Common.Exception.INVALID_NAMESACE_NAME_EXCEPTION",
                                                                   "invalid CIM namespace name: $0",
                                                                    name))
   {
   }
  
 const char CIMValueInvalidType::MSG[] = "invalid CIMValue type";  InvalidNamespaceNameException::InvalidNamespaceNameException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.INVALID_NAMESPACE_NAME_EXCEPTION",
                                                                   "invalid CIM namespace name: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char DynamicCastFailed::MSG[] = "dynamic cast failed";  /*
   UninitializedObjectException::UninitializedObjectException()
       : Exception("uninitialized object")
   {
   }
   */
  
 const char NoSuchFile::MSG[] = "no such file: ";  UninitializedObjectException::UninitializedObjectException()
       : Exception(MessageLoaderParms("Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
                                                                   "uninitialized object"))
   {
   }
  
 const char FileNotReadable::MSG[] = "file not readable: ";  /*
   TypeMismatchException::TypeMismatchException()
       : Exception("type mismatch")
   {
   }
   */
  
 const char CannotBindToAddress::MSG[] = "cannot bind to address: ";  TypeMismatchException::TypeMismatchException()
       : Exception(MessageLoaderParms("Common.Exception.TYPE_MISMATCH_EXCEPTION",
                                                                   "type mismatch"))
   {
   }
  
 const char NoSuchDirectory::MSG[] = "no such directory: ";  TypeMismatchException::TypeMismatchException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.TYPE_MISMATCH_EXCEPTION",
                                                                   "type mismatch: $0",message))
   {
  
 const char ChangeDirectoryFailed::MSG[] = "cannot change directory: ";  }
  
 const char CannotCreateDirectory::MSG[] = "cannot create directory: ";  TypeMismatchException::TypeMismatchException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.TYPE_MISMATCH_EXCEPTION",
                                                                   "type mismatch: "))
   {
       _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char NoSuchNameSpace::MSG[] = "no such namespace: ";  /*
   DynamicCastFailedException::DynamicCastFailedException()
       : Exception("dynamic cast failed")
   {
   }
   */
  
 const char CannotOpenFile::MSG[] = "cannot open file: ";  DynamicCastFailedException::DynamicCastFailedException()
       : Exception(MessageLoaderParms("Common.Exception.DYNAMIC_CAST_FAILED_EXCEPTION",
                                                                   "dynamic cast failed"))
   {
   }
  
 const char NotImplemented::MSG[] = "not implemented: ";  /*
   InvalidDateTimeFormatException::InvalidDateTimeFormatException()
       : Exception("invalid datetime format")
   {
   }
   */
  
 const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";  InvalidDateTimeFormatException::InvalidDateTimeFormatException()
       : Exception(MessageLoaderParms("Common.Exception.INVALID_DATETIME_FORMAT_EXCEPTION",
                                                                   "invalid datetime format"))
   {
   }
  
 const char CannotRemoveFile::MSG[] = "cannot remove file: ";  /*
   MalformedObjectNameException::MalformedObjectNameException(
       const String& objectName)
       : Exception("malformed object name: " + objectName)
   {
   }
   */
  
 const char CannotRenameFile::MSG[] = "cannot rename file: ";  MalformedObjectNameException::MalformedObjectNameException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
                                                                   "malformed object name: $0",
                                                                    message))
   {
   }
  
 const char StackUnderflow::MSG[] = "stack underflow";  MalformedObjectNameException::MalformedObjectNameException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
                                                                   "malformed object name: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char StackOverflow::MSG[] = "stack overflow";  /*
   BindFailedException::BindFailedException(const String& message)
       : Exception("Bind failed: " + message)
   {
   }
   */
  
 const char QueueUnderflow::MSG[] = "queue Underflow";  BindFailedException::BindFailedException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.BIND_FAILED_EXCEPTION",
                                                                   "Bind failed: $0",
                                                                    message))
   {
   }
  
 const char BadFormat::MSG[] = "bad format passed to Formatter::format()";  BindFailedException::BindFailedException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.BIND_FAILED_EXCEPTION",
                                                                   "Bind failed: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char BadDateTimeFormat::MSG[] = "bad datetime format";  /*
   InvalidLocatorException::InvalidLocatorException(const String& locator)
       : Exception("Invalid locator: " + locator)
   {
   }
   */
  
 const char IncompatibleTypes::MSG[] = "incompatible types";  InvalidLocatorException::InvalidLocatorException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.INVALID_LOCATOR_EXCEPTION",
                                                                   "Invalid locator: $0",
                                                                    message))
   {
   }
  
 const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";  InvalidLocatorException::InvalidLocatorException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.INVALID_LOCATOR_EXCEPTION",
                                                                   "Invalid locator: "))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char IllformedObjectName::MSG[] = "illformed object name: ";  /*
   CannotCreateSocketException::CannotCreateSocketException()
       : Exception("Cannot create socket")
   {
   }
   */
  
 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("already connected")
   {
   }
   */
  
 const char CannotCreateSocket::MSG[] = "Cannot create socket";  AlreadyConnectedException::AlreadyConnectedException()
       : Exception(MessageLoaderParms("Common.Exception.ALREADY_CONNECTED_EXCEPTION",
                                                                   "already connected"))
   {
   }
  
 const char CannotConnect::MSG[] = "Cannot connect to: ";  /*
   NotConnectedException::NotConnectedException()
       : Exception("not connected")
   {
   }
   */
  
 const char UnexpectedFailure::MSG[] = "Unexpected failure";  NotConnectedException::NotConnectedException()
       : Exception(MessageLoaderParms("Common.Exception.NOT_CONNECTED_EXCEPTION",
                                                                   "not connected"))
   {
   }
  
 const char AlreadyConnected::MSG[] = "already connected";  /*
   ConnectionTimeoutException::ConnectionTimeoutException()
       : Exception("connection timed out")
   {
   }
   */
  
 const char NotConnected::MSG[] = "not connected";  ConnectionTimeoutException::ConnectionTimeoutException()
       : Exception(MessageLoaderParms("Common.Exception.CONNECTION_TIMEOUT_EXCEPTION",
                                                                   "connection timed out"))
   {
   }
  
 const char TimedOut::MSG[] = "timed out";  /*
   SSLException::SSLException(const String& message)
       : Exception("SSL Exception: " + message)
   {
   }
   */
  
 const char ParseError::MSG[] = "parse error: ";  SSLException::SSLException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.SSL_EXCEPTION",
                                                                   "SSL Exception: $0" ,
                                                                    message))
   {
   }
  
 const char MissingNullTerminator::MSG[] = "missing null terminator: ";  SSLException::SSLException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.SSL_EXCEPTION",
                                                                   "SSL Exception: " ))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
 const char SSL_Exception::MSG[] = "SSL Exception ";  /*
   DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
       : Exception("DateTime is out of range : " + message)
   {
   }
   */
  
 const char InvalidAuthHeader::MSG[] = "Invalid Authorization header";  DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
       : Exception(MessageLoaderParms("Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
                                                                   "DateTime is out of range : $0" ,
                                                                    message))
   {
   }
  
 const char UnauthorizedAccess::MSG[] = "Unauthorized access";  DateTimeOutOfRangeException::DateTimeOutOfRangeException(MessageLoaderParms& msgParms)
       : Exception(MessageLoaderParms("Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
                                                                   "DateTime is out of range : " ))
   {
           _rep->message.append(MessageLoader::getMessage(msgParms));
   }
  
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Line 211 
Line 414 
 // //
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
  
 //  // l10n - note - use this when you have an exception with no
 // Creates a description without source file name and line number.  // detail message, or one with an untranslated detail message
 //  // The pegasus message associated with code will be translated.
 static String _makeCIMExceptionDescription(  CIMException::CIMException(
     CIMStatusCode code,     CIMStatusCode code,
     const String& message)     const String& message)
       : Exception()
 { {
     String tmp;      CIMExceptionRep * tmp = new CIMExceptionRep ();
     tmp.append(CIMStatusCodeToString(code));      tmp->message = message;
     if (message != String::EMPTY)      tmp->code = code;
     {      tmp->file = "";
         tmp.append(": \"");      tmp->line = 0;
         tmp.append(message);      tmp->contentLanguages = ContentLanguages::EMPTY;
         tmp.append("\"");      tmp->cimMessage = String::EMPTY;
     }      _rep = tmp;
     return tmp;  
 }  
   
 //  
 // 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;  
 } }
  
   // l10n - note use this when you have an exception with a translated
   // detail message
   // l10n
 CIMException::CIMException( CIMException::CIMException(
     CIMStatusCode code,     CIMStatusCode code,
     const String& message,      const MessageLoaderParms& msgParms)
     const char* file,      : Exception()
     Uint32 line)  
     :  
     Exception(message),  
     _code(code),  
     _file(file),  
     _line(line)  
 { {
       CIMExceptionRep * tmp = new CIMExceptionRep ();
 }      tmp->message = MessageLoader::getMessage(
           const_cast<MessageLoaderParms &>(msgParms));
 //      // Must be after MessageLoader::getMessage call
 // Returns a description string fit for human consumption      tmp->contentLanguages = msgParms.contentlanguages;
 //      tmp->cimMessage = String::EMPTY;
 String CIMException::getDescription() const      tmp->code = code;
 {      tmp->file = "";
 #ifdef DEBUG_CIMEXCEPTION      tmp->line = 0;
     return getTraceDescription();      _rep = tmp;
 #else  }
     return _makeCIMExceptionDescription(_code, getMessage());  
 #endif  CIMException::CIMException(const CIMException & cimException)
 }      : Exception()
   {
 //      CIMExceptionRep * tmp = new CIMExceptionRep ();
 // Returns a description string with filename and line number information      CIMExceptionRep * rep;
 // specifically for tracing.      rep = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
 //      tmp->message = rep->message;
 String CIMException::getTraceDescription() const      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::operator=(const CIMException & cimException)
   {
       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()
 { {
     String traceDescription =  
         _makeCIMExceptionDescription(_code, getMessage(), _file, _line);  
   
     return traceDescription;  
 } }
  
 void ThrowUninitializedHandle()  CIMStatusCode CIMException::getCode() const
 {  {
     throw UninitializedHandle();      CIMExceptionRep* rep;
       rep = reinterpret_cast<CIMExceptionRep*>(_rep);
       return rep->code;
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.42  
changed lines
  Added in v.1.71

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2