(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.34 and 1.58

version 1.34, 2002/04/12 21:12:01 version 1.58, 2002/09/11 21:58:02
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 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 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 22 
Line 23 
 // //
 // 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)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <cstdio> #include <cstdio>
 #include "Exception.h" #include "Exception.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) : _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, "%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";  
   
 const char AlreadyExists::MSG[] = "already exists: ";  
   
 const char NullPointer::MSG[] = "null pointer";  
   
 const char UnitializedHandle::MSG[] = "unitialized 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[] =  
     "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 instantiate an abstract class ";  
   
 const char NoSuchProperty::MSG[] = "no such property: ";  
   
 const char TruncatedCharacter::MSG[] =  
     "truncated character during conversion from Char16 to char";  
   
 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";  
   
 const char IllegalTypeTag::MSG[] = "illegal type tag";  
   
 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 FileNotReadable::MSG[] = "file not readable: ";  
   
 const char CannotBindToAddress::MSG[] = "cannot bind to address: ";  
   
 const char NoSuchDirectory::MSG[] = "no such directory: ";  
   
 const char ChangeDirectoryFailed::MSG[] = "cannot change directory: ";  
   
 const char CannotCreateDirectory::MSG[] = "cannot create directory: ";  
   
 const char NoSuchNameSpace::MSG[] = "no such namespace: ";  
   
 const char CannotOpenFile::MSG[] = "cannot open file: ";  
   
 const char NotImplemented::MSG[] = "not implemented: ";  
   
 const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";  
   
 const char CannotRemoveFile::MSG[] = "cannot remove file: ";  
   
 const char CannotRenameFile::MSG[] = "cannot rename file: ";  
   
 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 BadDateTimeFormat::MSG[] = "bad datetime format";  
   
 const char IncompatibleTypes::MSG[] = "incompatible types";  
   
 const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";  
   
 const char IllformedObjectName::MSG[] = "illformed object name: ";  
   
 const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";  
   
 const char DynamicLookupFailed::MSG[] =  
     "lookup of symbol in dynamic library failed: ";  
   
 const char CannotOpenDirectory::MSG[] = "cannot open directory: ";  
   
 const char CorruptFile::MSG[] = "corrupt file: ";  
   
 const char BindFailed::MSG[] = "Bind failed: ";  
  
 const char InvalidLocator::MSG[] = "Invalid locator: ";  IndexOutOfBoundsException::IndexOutOfBoundsException()
       : Exception("index out of bounds")
 const char CannotCreateSocket::MSG[] = "Cannot create socket";  {
   }
 const char CannotConnect::MSG[] = "Cannot connect to: ";  
   
 const char UnexpectedFailure::MSG[] = "Unexpected failure";  
   
 const char FailedToConnect::MSG[] = "failed to connect";  
  
 const char AlreadyConnected::MSG[] = "already connected";  AlreadyExistsException::AlreadyExistsException(const String& message)
       : Exception("already exists: " + message)
   {
   }
  
 const char NotConnected::MSG[] = "not connected";  InvalidNameException::InvalidNameException(const String& name)
       : Exception("invalid CIM name: " + name)
   {
   }
  
 const char TimedOut::MSG[] = "timed out";  InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
       : Exception("invalid CIM namespace name: " + name)
   {
   }
  
 const char ParseError::MSG[] = "parse error: ";  UninitializedObjectException::UninitializedObjectException()
       : Exception("uninitialized object")
   {
   }
  
 const char MissingNullTerminator::MSG[] = "missing null terminator: ";  TypeMismatchException::TypeMismatchException()
       : Exception("type mismatch")
   {
   }
  
 const char SSL_Exception::MSG[] = "SSL Exception ";  InvalidTypeException::InvalidTypeException()
       : Exception("invalid CIM type")
   {
   }
  
 const char InvalidAuthHeader::MSG[] = "Invalid Authorization header";  DynamicCastFailedException::DynamicCastFailedException()
       : Exception("dynamic cast failed")
   {
   }
  
   InvalidDateTimeFormatException::InvalidDateTimeFormatException()
       : Exception("invalid datetime format")
   {
   }
  
 ////////////////////////////////////////////////////////////////////////////////  MalformedObjectNameException::MalformedObjectNameException(
 //      const String& objectName)
 // CIMException      : Exception("malformed object name: " + objectName)
 //  {
 ////////////////////////////////////////////////////////////////////////////////  }
  
 //  BindFailedException::BindFailedException(const String& message)
 // Creates a message without source file name and line number.      : Exception("Bind failed: " + message)
 //  
 static String _makeCIMExceptionMessage(  
     CIMStatusCode code,  
     const String& description)  
 { {
     String tmp;  
     tmp.append(CIMStatusCodeToString(code));  
     tmp.append(": \"");  
     tmp.append(description);  
     tmp.append("\"");  
     return tmp;  
 } }
  
 //  InvalidLocatorException::InvalidLocatorException(const String& locator)
 // Creates a message with source file name and line number.      : Exception("Invalid locator: " + locator)
 //  {
 static String _makeCIMExceptionMessage(  
     CIMStatusCode code,  
     const String& description,  
     const char* file,  
     Uint32 line)  
 {  
     String tmp = file;  
     tmp.append("(");  
     char buffer[32];  
     sprintf(buffer, "%d", line);  
     tmp.append(buffer);  
     tmp.append("): ");  
   
     tmp.append(CIMStatusCodeToString(code));  
     tmp.append(": \"");  
     tmp.append(description);  
     tmp.append("\"");  
     return tmp;  
 } }
  
 //  CannotCreateSocketException::CannotCreateSocketException()
 // Returns a message string specifically for tracing.      : Exception("Cannot create socket")
 //  
 String CIMException::getTraceMessage() const  
 { {
     String traceMsg =  }
         _makeCIMExceptionMessage(_code, _description, _file, _line);  
  
     return traceMsg;  CannotConnectException::CannotConnectException(const String& locator)
       : Exception("Cannot connect to: " + locator)
   {
 } }
  
 CIMException::CIMException(  AlreadyConnectedException::AlreadyConnectedException()
     CIMStatusCode code,      : Exception("already connected")
     const String& description,  
     const char* file,  
     Uint32 line)  
     :  
 #ifdef DEBUG_CIMEXCEPTION  
     Exception(_makeCIMExceptionMessage(code, description, file, line)),  
 #else  
     Exception(_makeCIMExceptionMessage(code, description)),  
 #endif  
     _code(code),  
     _description(description),  
     _file(file),  
     _line(line)  
 { {
   }
  
   NotConnectedException::NotConnectedException()
       : Exception("not connected")
   {
 } }
  
 CIMException::CIMException(const CIMException& cimException)  ConnectionTimeoutException::ConnectionTimeoutException()
     : Exception(cimException.getMessage()),      : Exception("connection timed out")
     _code(cimException._code),  
     _description(cimException._description),  
     _file(cimException._file),  
     _line(cimException._line)  
 { {
 } }
  
 void ThrowUnitializedHandle()  SSLException::SSLException(const String& message)
       : Exception("SSL Exception: " + message)
 { {
     throw UnitializedHandle();  
 } }
  
   
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // //
 // HTTPError  // CIMException
 // //
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
  
 static String _makeHTTPErrorMessage(  CIMException::CIMException(
     Uint32 httpStatusCode,      CIMStatusCode code,
     const String& cimError,      const String& message)
     const String& pegasusError)      :
       Exception(message)
 { {
     String tmp = "HTTP Error (status code ";      _rep = new CIMExceptionRep();
     char buffer[32];      _rep->code = code;
     sprintf(buffer, "%u", httpStatusCode);      _rep->file = "";
     tmp.append(buffer);      _rep->line = 0;
     tmp.append(")");  }
  
     if ((cimError != String::EMPTY) || (pegasusError != String::EMPTY))  CIMException::CIMException(const CIMException & cimException)
     {      : Exception(cimException.getMessage())
         tmp.append(":");  
         if (cimError != String::EMPTY)  
         {         {
             tmp.append(" CIMError = \"");      _rep = new CIMExceptionRep();
             tmp.append(cimError);      _rep->code = cimException._rep->code;
             tmp.append("\"");      _rep->file = cimException._rep->file;
       _rep->line = cimException._rep->line;
         }         }
         if (pegasusError != String::EMPTY)  
   CIMException& CIMException::operator=(const CIMException & cimException)
         {         {
             tmp.append(" Detail = \"");      _message = cimException._message;
             tmp.append(pegasusError);      _rep->code = cimException._rep->code;
             tmp.append("\"");      _rep->file = cimException._rep->file;
         }      _rep->line = cimException._rep->line;
     }      return *this;
     tmp.append(".");  
     return tmp;  
 } }
  
 HTTPError::HTTPError(  CIMException::~CIMException()
     Uint32 httpStatusCode,  
     const String& cimError,  
     const String& pegasusError)  
     :  
     Exception(_makeHTTPErrorMessage(httpStatusCode, cimError, pegasusError)),  
     _httpStatusCode(httpStatusCode),  
     _cimError(cimError),  
     _pegasusError(pegasusError)  
 { {
       delete _rep;
 } }
  
 HTTPError::HTTPError(const HTTPError& httpError)  CIMStatusCode CIMException::getCode() const
     :  
     Exception(httpError.getMessage()),  
     _httpStatusCode(httpError._httpStatusCode),  
     _cimError(httpError._cimError),  
     _pegasusError(httpError._pegasusError)  
 { {
       return _rep->code;
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.34  
changed lines
  Added in v.1.58

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2