1 //%2006////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //==============================================================================
32 //%/////////////////////////////////////////////////////////////////////////////
34 #ifndef Pegasus_Exception_h
35 #define Pegasus_Exception_h
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/String.h>
39 #include <Pegasus/Common/CIMStatusCode.h>
40 #include <Pegasus/Common/Linkage.h>
41 #include <Pegasus/Common/ContentLanguageList.h>
42 #include <Pegasus/Common/Array.h>
44 #ifdef PEGASUS_INTERNALONLY
45 # include <Pegasus/Common/MessageLoader.h>
48 PEGASUS_NAMESPACE_BEGIN
51 class CIMConstInstance;
55 <p>The <tt>Exception</tt> class is the parent class for all
56 exceptions that can be generated by any component of the
57 Pegasus infrastructure. It includes not only the CIM exceptions
58 that are defined by the DMTF, but also various exceptions that
59 may occur during the processing of functions called by clients
62 class PEGASUS_COMMON_LINKAGE Exception
67 Exception(const String& message);
70 Exception(const Exception& exception);
72 #ifdef PEGASUS_INTERNALONLY
73 Exception(const MessageLoaderParms& msgParms);
80 virtual const String& getMessage() const;
82 #ifdef PEGASUS_INTERNALONLY
83 // Note: Not virtual to preserve binary compatibility.
84 const ContentLanguageList& getContentLanguages() const;
86 // Not virtual to preserve binary compatibility.
87 void setContentLanguages(const ContentLanguageList& langs);
98 class PEGASUS_COMMON_LINKAGE IndexOutOfBoundsException : public Exception
102 IndexOutOfBoundsException();
106 class PEGASUS_COMMON_LINKAGE AlreadyExistsException : public Exception
110 AlreadyExistsException(const String& message);
112 #ifdef PEGASUS_INTERNALONLY
113 AlreadyExistsException(MessageLoaderParms& msgParms);
118 class PEGASUS_COMMON_LINKAGE InvalidNameException : public Exception
122 InvalidNameException(const String& name);
124 #ifdef PEGASUS_INTERNALONLY
125 InvalidNameException(MessageLoaderParms& msgParms);
130 class PEGASUS_COMMON_LINKAGE InvalidNamespaceNameException : public Exception
134 InvalidNamespaceNameException(const String& name);
136 #ifdef PEGASUS_INTERNALONLY
137 InvalidNamespaceNameException(MessageLoaderParms& msgParms);
142 class PEGASUS_COMMON_LINKAGE UninitializedObjectException : public Exception
146 UninitializedObjectException();
150 class PEGASUS_COMMON_LINKAGE TypeMismatchException : public Exception
154 TypeMismatchException();
155 TypeMismatchException(const String& message);
157 #ifdef PEGASUS_INTERNALONLY
158 TypeMismatchException(MessageLoaderParms& msgParms);
164 class PEGASUS_COMMON_LINKAGE DynamicCastFailedException : public Exception
168 DynamicCastFailedException();
172 class PEGASUS_COMMON_LINKAGE InvalidDateTimeFormatException : public Exception
176 InvalidDateTimeFormatException();
180 class PEGASUS_COMMON_LINKAGE MalformedObjectNameException : public Exception
184 MalformedObjectNameException(const String& objectName);
186 #ifdef PEGASUS_INTERNALONLY
187 MalformedObjectNameException(MessageLoaderParms& msgParms);
192 class PEGASUS_COMMON_LINKAGE BindFailedException : public Exception
196 BindFailedException(const String& message);
198 #ifdef PEGASUS_INTERNALONLY
199 BindFailedException(MessageLoaderParms& msgParms);
204 class PEGASUS_COMMON_LINKAGE InvalidLocatorException : public Exception
208 InvalidLocatorException(const String& locator);
210 #ifdef PEGASUS_INTERNALONLY
211 InvalidLocatorException(MessageLoaderParms& msgParms);
216 class PEGASUS_COMMON_LINKAGE CannotCreateSocketException : public Exception
220 CannotCreateSocketException();
224 class PEGASUS_COMMON_LINKAGE CannotConnectException : public Exception
228 CannotConnectException(const String& message);
230 #ifdef PEGASUS_INTERNALONLY
231 CannotConnectException(MessageLoaderParms& msgParms);
236 class PEGASUS_COMMON_LINKAGE AlreadyConnectedException: public Exception
240 AlreadyConnectedException();
244 class PEGASUS_COMMON_LINKAGE NotConnectedException: public Exception
248 NotConnectedException();
252 class PEGASUS_COMMON_LINKAGE ConnectionTimeoutException: public Exception
256 ConnectionTimeoutException();
260 class PEGASUS_COMMON_LINKAGE SSLException: public Exception
264 SSLException(const String& message);
266 #ifdef PEGASUS_INTERNALONLY
267 SSLException(MessageLoaderParms& msgParms);
272 class PEGASUS_COMMON_LINKAGE DateTimeOutOfRangeException : public Exception
276 DateTimeOutOfRangeException(const String& message);
278 #ifdef PEGASUS_INTERNALONLY
279 DateTimeOutOfRangeException(MessageLoaderParms& msgParms);
283 /** The CIMException defines the CIM exceptions that are formally defined in
284 the CIM Operations over HTTP specification.
286 class PEGASUS_COMMON_LINKAGE CIMException : public Exception
290 /** Construct a CIMException with status code and Error description
292 @param code CIMStatus code defining the error
293 @param message String defining the message text
294 @param instance CIMInstance containing the CIM_Error
298 CIMStatusCode code = CIM_ERR_SUCCESS,
299 const String& message = String::EMPTY);
301 /** Construct a CIMException with status code, message
302 and a CIM_Error instance attached to the exception. Note that
303 this allows the CIMStatusCode and Description in the CIMError
304 to be different than those attached to the call.
305 @param code CIMStatus code defining the error
306 @param message String defining the message text
307 @param instance CIMInstance containing the CIM_Error
312 const String& message,
313 const CIMInstance& instance);
315 /** Construct a CIMException with status code, message
316 and an Array of CIM_Error instances attached to the exception.
317 Note that this allows the CIMStatusCode and Description in the
318 CIMErrors to be different than those attached to the call.
319 @param code CIMStatus code defining the error
320 @param message String defining the message text
321 @param instances Array<CIMInstance> containing CIM_Error
327 const String& message,
328 const Array<CIMInstance>& instances);
330 #ifdef PEGASUS_INTERNALONLY
333 const MessageLoaderParms& msgParms);
337 const MessageLoaderParms& msgParms,
338 const CIMInstance& instance);
341 const MessageLoaderParms& msgParms,
342 const Array<CIMInstance>& instances);
346 CIMException(const CIMException & cimException);
349 CIMException& operator=(const CIMException & cimException);
352 virtual ~CIMException();
354 /** gets the CIMStatusCode for the current CIMException. This is the
355 code that defines the ERROR that was executed and transmitted
357 @return a single CIMStatusCode
358 @SeeAlso CIMStatusCode
361 { .. Execute CIM Operation
363 catch (CIMExcepton e)
365 if (e.getCode() == CIM_ERR_ACCESS_DENIED )
369 CIMStatusCode getCode() const;
371 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
373 /* get the count of CIM_Error instances attached to the CIMException.
374 Normally this method is used by the client to determine if any
375 CIM_Error instances are attached to a CIMException and as the
376 end test if the user decides to get the exception instances.
377 @return Uint32 count of CIM_Error instances attached to a CIMException.
378 0 indicates that there are no instances attached.
380 Uint32 getErrorCount() const;
382 /* get a single CIM_Error instance that is attached to a CIMException.
383 @param Uint32 index that defines the index to a particular CIMInstance
384 attached to the CIMException. The index must be less than the value of
385 the return from getErrorCount()
386 Return CIMInstance the instance defined by the index.
387 exception: returns out-of-range exception if the index is outside the
388 range of the array of CIM_Instances attached to the CIMExcepton.
391 { .. Execute CIM Operation
393 catch (CIMExcepton e)
395 if (e.getErrorCount() > 0 )
397 for (Uint32 i = 0 ; i < getErrorCount() ; i++)
398 ... get and process each CIM_Error instance
403 CIMConstInstance getError(Uint32 index) const;
405 //CIMInstance getError(Uint32 index);
407 /* Adds a single error instance to a CIMException
408 @param instance CIMInstance is the instance of CIM_Error
409 that is to be added to the CIMException. This instance is
410 NOT checked by the infrastructure for correct type.
412 void addError(const CIMInstance& instance);
414 #endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */
418 PEGASUS_NAMESPACE_END
420 #endif /* Pegasus_Exception_h */