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

  1 mike  1.18 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3            // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4            //
  5            // Permission is hereby granted, free of charge, to any person obtaining a copy
  6            // of this software and associated documentation files (the "Software"), to 
  7            // deal in the Software without restriction, including without limitation the 
  8            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
  9            // sell copies of the Software, and to permit persons to whom the Software is
 10            // furnished to do so, subject to the following conditions:
 11            // 
 12            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 16            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 17            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 18            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20            //
 21            //==============================================================================
 22 mike  1.18 //
 23            // Author: Mike Brasher (mbrasher@bmc.com)
 24            //
 25            // Modified By:
 26            //
 27            //%/////////////////////////////////////////////////////////////////////////////
 28            
 29            #ifndef Pegasus_Exception_h
 30            #define Pegasus_Exception_h
 31            
 32            #include <cstring>
 33            #include <Pegasus/Common/Config.h>
 34            #include <Pegasus/Common/String.h>
 35            
 36            PEGASUS_NAMESPACE_BEGIN
 37            
 38            /** Class Exception  - This 
 39            */
 40            class PEGASUS_COMMON_LINKAGE Exception
 41            {
 42            public:
 43 mike  1.18 
 44                Exception(const String& message);
 45            
 46                Exception(const char* message);
 47            
 48                ~Exception();
 49            
 50                const String& getMessage() const { return _message; }
 51            
 52            protected:
 53            
 54                String _message;
 55            };
 56            
 57            /** Class AssertionFailureException
 58            This is an Exception class tied to the definiton of an assert named
 59            PEGASUS_ASSERT.  This assertion can be included at any point in Pegasus
 60            code
 61            */
 62            class PEGASUS_COMMON_LINKAGE AssertionFailureException : public Exception
 63            {
 64 mike  1.18 public:
 65            
 66                AssertionFailureException(
 67            	const char* file,
 68            	size_t line,
 69            	const String& message);
 70            };
 71            
 72            /** define PEGASUS_ASSERT assertion statement.  This statement tests the 
 73                condition defined by the parameters and if not True executes an 
 74            
 75                <pre>
 76                throw AssertionFailureException
 77                </pre>
 78            
 79                defining the file, line and condition that was tested.
 80            */
 81            #define PEGASUS_ASSERT(COND) \
 82                do \
 83                { \
 84            	if (!(COND)) \
 85 mike  1.18 	{ \
 86            	    throw AssertionFailureException(__FILE__, __LINE__, #COND); \
 87            	} \
 88                } while (0)
 89            
 90            /// ATTN:
 91            class PEGASUS_COMMON_LINKAGE BadReference : public Exception
 92            {
 93            public:
 94            
 95                BadReference(const String& message) : Exception(message) { }
 96            };
 97            
 98            /// ATTN:
 99            class PEGASUS_COMMON_LINKAGE OutOfBounds : public Exception
100            {
101            public:
102            
103                static const char MSG[];
104            
105                OutOfBounds() : Exception(MSG) { }
106 mike  1.18 };
107            
108            /// ATTN:
109            class PEGASUS_COMMON_LINKAGE AlreadyExists : public Exception
110            {
111            public:
112            
113                static const char MSG[];
114            
115                AlreadyExists(const String& x = String()) : Exception(MSG + x) { }
116            };
117            
118            /// ATTN:
119            class PEGASUS_COMMON_LINKAGE NullPointer : public Exception
120            {
121            public:
122            
123                static const char MSG[];
124            
125                NullPointer() : Exception(MSG) { }
126            };
127 mike  1.18 
128            /// ATTN:
129            class PEGASUS_COMMON_LINKAGE IllegalName : public Exception
130            {
131            public:
132            
133                static const char MSG[];
134            
135                IllegalName() : Exception(MSG) { }
136            };
137            
138            /// ATTN:
139            class PEGASUS_COMMON_LINKAGE UnitializedHandle : public Exception
140            {
141            public:
142            
143                static const char MSG[];
144            
145                UnitializedHandle() : Exception(MSG) { }
146            };
147            
148 mike  1.18 /// ATTN:
149            class PEGASUS_COMMON_LINKAGE InvalidPropertyOverride : public Exception
150            {
151            public:
152            
153                static const char MSG[];
154            
155                InvalidPropertyOverride(const String& message)
156            	: Exception(MSG + message) { }
157            };
158            
159            /// ATTN:
160            class PEGASUS_COMMON_LINKAGE InvalidMethodOverride : public Exception
161            {
162            public:
163            
164                static const char MSG[];
165            
166                InvalidMethodOverride(const String& message)
167            	: Exception(MSG + message) { }
168            };
169 mike  1.18 
170            /// ATTN:
171            class PEGASUS_COMMON_LINKAGE UndeclaredQualifier : public Exception
172            {
173            public:
174            
175                static const char MSG[];
176            
177                UndeclaredQualifier(const String& qualifierName)
178            	: Exception(MSG + qualifierName) { }
179            };
180            
181            /// ATTN:
182            class PEGASUS_COMMON_LINKAGE BadQualifierScope : public Exception
183            {
184            public:
185            
186                static const char MSG[];
187            
188                BadQualifierScope(const String& qualifierName, const String& scopeString)
189            	: Exception(MSG + qualifierName + String(" scope=") + scopeString) { }
190 mike  1.18 };
191            
192            /// ATTN:
193            class PEGASUS_COMMON_LINKAGE BadQualifierOverride : public Exception
194            {
195            public:
196            
197                static const char MSG[];
198            
199                BadQualifierOverride(const String& qualifierName)
200            	: Exception(MSG + qualifierName) { }
201            };
202            
203            class PEGASUS_COMMON_LINKAGE BadQualifierType : public Exception
204            {
205            public:
206            
207                static const char MSG[];
208            
209                BadQualifierType(const String& qualifierName)
210            	: Exception(MSG + qualifierName) { }
211 mike  1.18 };
212            
213            /// ATTN:
214            class PEGASUS_COMMON_LINKAGE NullType : public Exception
215            {
216            public:
217            
218                static const char MSG[];
219            
220                NullType() : Exception(MSG) { }
221            };
222            
223            /// ATTN:
224            class PEGASUS_COMMON_LINKAGE AddedReferenceToClass : public Exception
225            {
226            public:
227            
228                static const char MSG[];
229            
230                AddedReferenceToClass(const String& className)
231            	: Exception(MSG + className) { }
232 mike  1.18 };
233            
234            /// ATTN:
235            class PEGASUS_COMMON_LINKAGE ClassAlreadyResolved : public Exception
236            {
237            public:
238            
239                static const char MSG[];
240            
241                ClassAlreadyResolved(const String& className)
242            	: Exception(MSG + className) { }
243            };
244            
245            /// ATTN:
246            class PEGASUS_COMMON_LINKAGE ClassNotResolved : public Exception
247            {
248            public:
249            
250                static const char MSG[];
251            
252                ClassNotResolved(const String& className)
253 mike  1.18 	: Exception(MSG + className) { }
254            };
255            
256            /// ATTN:
257            class PEGASUS_COMMON_LINKAGE InstanceAlreadyResolved : public Exception
258            {
259            public:
260            
261                static const char MSG[];
262            
263                InstanceAlreadyResolved() : Exception(MSG) { }
264            };
265            
266            /// ATTN:
267            class PEGASUS_COMMON_LINKAGE InstantiatedAbstractClass : public Exception
268            {
269            public:
270            
271                static const char MSG[];
272            
273                InstantiatedAbstractClass() : Exception(MSG) { }
274 mike  1.18 };
275 mike  1.19 
276 mike  1.18 /// ATTN:
277            class PEGASUS_COMMON_LINKAGE NoSuchProperty : public Exception
278            {
279            public:
280            
281                static const char MSG[];
282            
283                NoSuchProperty(const String& propertyName)
284            	: Exception(MSG + propertyName) { }
285            };
286 mike  1.19 
287 mike  1.18 /// ATTN:
288            class PEGASUS_COMMON_LINKAGE TruncatedCharacter : public Exception
289            {
290            public:
291            
292                static const char MSG[];
293            
294                TruncatedCharacter() : Exception(MSG) { }
295            };
296 mike  1.19 
297 mike  1.18 /// ATTN:
298            class PEGASUS_COMMON_LINKAGE ExpectedReferenceValue : public Exception
299            {
300            public:
301            
302                static const char MSG[];
303            
304                ExpectedReferenceValue() : Exception(MSG) { }
305            };
306 mike  1.19 
307 mike  1.18 /// ATTN:
308            class PEGASUS_COMMON_LINKAGE MissingReferenceClassName : public Exception
309            {
310            public:
311            
312                static const char MSG[];
313            
314                MissingReferenceClassName() : Exception(MSG) { }
315            };
316 mike  1.19 
317 mike  1.18 /// ATTN:
318            class PEGASUS_COMMON_LINKAGE IllegalTypeTag : public Exception
319            {
320            public:
321            
322                static const char MSG[];
323            
324                IllegalTypeTag() : Exception(MSG) { }
325            };
326 mike  1.19 
327 mike  1.18 /// ATTN:
328            class PEGASUS_COMMON_LINKAGE TypeMismatch : public Exception
329            {
330            public:
331            
332                static const char MSG[];
333            
334                TypeMismatch() : Exception(MSG) { }
335            };
336 mike  1.19 
337 mike  1.18 /// ATTN:
338            class PEGASUS_COMMON_LINKAGE NoSuchFile : public Exception
339            {
340            public:
341            
342                static const char MSG[];
343            
344                NoSuchFile(const String& fileName) : Exception(MSG + fileName) { }
345            };
346            class PEGASUS_COMMON_LINKAGE CannotBindToAddress : public Exception
347            {
348            public:
349            
350                static const char MSG[];
351            
352                CannotBindToAddress(const String& address) : Exception(MSG + address) { }
353            };
354            
355            /// ATTN:
356            class PEGASUS_COMMON_LINKAGE CannotRemoveDirectory : public Exception
357            {
358 mike  1.18 public:
359            
360                static const char MSG[];
361            
362                CannotRemoveDirectory(const String& path) : Exception(MSG + path) { }
363            };
364            
365            /// ATTN:
366            class PEGASUS_COMMON_LINKAGE CannotRemoveFile : public Exception
367            {
368            public:
369            
370                static const char MSG[];
371            
372                CannotRemoveFile(const String& path) : Exception(MSG + path) { }
373            };
374            
375            /// ATTN:
376            class PEGASUS_COMMON_LINKAGE CannotRenameFile : public Exception
377            {
378            public:
379 mike  1.18 
380                static const char MSG[];
381            
382                CannotRenameFile(const String& path) : Exception(MSG + path) { }
383            };
384            
385            /// ATTN:
386            class PEGASUS_COMMON_LINKAGE NoSuchDirectory : public Exception
387            {
388            public:
389            
390                static const char MSG[];
391            
392                NoSuchDirectory(const String& directoryName)
393            	: Exception(MSG + directoryName) { }
394            };
395            
396            class PEGASUS_COMMON_LINKAGE ChangeDirectoryFailed : public Exception
397            {
398            public:
399            
400 mike  1.18     static const char MSG[];
401            
402                ChangeDirectoryFailed(const String& directoryName)
403            	: Exception(MSG + directoryName) { }
404            };
405 mike  1.19 
406 mike  1.18 /// ATTN:
407            class PEGASUS_COMMON_LINKAGE CannotCreateDirectory : public Exception
408            {
409            public:
410            
411                static const char MSG[];
412            
413                CannotCreateDirectory(const String& path)
414            	: Exception(MSG + path) { }
415            };
416 mike  1.19 
417 mike  1.18 /// ATTN:
418            class PEGASUS_COMMON_LINKAGE NoSuchNameSpace : public Exception
419            {
420            public:
421            
422                static const char MSG[];
423            
424                NoSuchNameSpace(const String& directoryName)
425            	: Exception(MSG + directoryName) { }
426            };
427            
428            /// ATTN:
429            class PEGASUS_COMMON_LINKAGE CannotOpenFile : public Exception
430            {
431            public:
432            
433                static const char MSG[];
434            
435                CannotOpenFile(const String& path)
436            	: Exception(MSG + path) { }
437            };
438 mike  1.18 
439            /// ATTN:
440            class PEGASUS_COMMON_LINKAGE NotImplemented : public Exception
441            {
442            public:
443            
444                static const char MSG[];
445            
446                NotImplemented(const String& method) : Exception(MSG + method) { }
447            };
448            
449            #define PEGASUS_CIM_EXCEPTION(CODE, EXTRA_MESSAGE) \
450                CIMException(CIMException::CODE, __FILE__, __LINE__, EXTRA_MESSAGE)
451            
452            /** The CIMException defines the CIM exceptions that are formally defined in 
453                the CIM Operations over HTTP specification.
454                @example
455                <PRE>
456            	throw CIMException(CIMException::NOT_SUPPORTED);
457                </PRE>
458            */
459 mike  1.18 class PEGASUS_COMMON_LINKAGE CIMException : public Exception
460            {
461            public:
462            
463                enum Code
464                {
465            	SUCCESS = 0,
466            
467            	// A general error occurred that is not covered by a more
468            	// specific error code.
469            
470            	FAILED = 1,
471            
472            	// Access to a CIM resource was not available to the client.
473            
474            	ACCESS_DENIED = 2,
475            
476            	// The target namespace does not exist.
477            
478            	INVALID_NAMESPACE = 3,
479            
480 mike  1.18 	// One or more parameter values passed to the method were invalid.
481            
482            	INVALID_PARAMETER = 4,
483            
484            	// The specified class does not exist.
485            
486            	INVALID_CLASS = 5,
487            
488            	// The requested object could not be found.
489            
490            	NOT_FOUND = 6,
491            
492            	// The requested operation is not supported.
493            
494            	NOT_SUPPORTED = 7,
495            
496            	// Operation cannot be carried out on this class since it has
497            	// subclasses.
498            
499            	CLASS_HAS_CHILDREN = 8,
500            
501 mike  1.18 	// Operation cannot be carried out on this class since it has
502            	// instances.
503            
504            	CLASS_HAS_INSTANCES = 9,
505            
506            	// Operation cannot be carried out since the specified superClass
507            	// does not exist.
508            
509            	INVALID_SUPERCLASS = 10,
510            
511            	// Operation cannot be carried out because an object already exists.
512            
513            	ALREADY_EXISTS = 11,
514            
515            	// The specified property does not exist:
516            
517            	NO_SUCH_PROPERTY = 12,
518            
519            	// The value supplied is incompatible with the type.
520            
521            	TYPE_MISMATCH = 13,
522 mike  1.18 
523            	// The query language is not recognized or supported.
524            
525            	QUERY_LANGUAGE_NOT_SUPPORTED = 14,
526            
527            	// The query is not valid for the specified query language.
528            
529            	INVALID_QUERY = 15,
530            
531            	// The extrinsic method could not be executed.
532            
533            	METHOD_NOT_AVAILABLE = 16,
534            
535            	// The specified extrinsic method does not exist.
536            
537            	METHOD_NOT_FOUND = 17
538                };
539            
540                CIMException(
541            	Code code, 
542            	const char* file = "",
543 mike  1.18 	Uint32 line = 0,
544            	const String& extraMessage = String());
545            
546                CIMException::Code getCode() const { return _code; }
547            
548                static const char* codeToString(Code code);
549            
550            private:
551            
552                Code _code;
553            };
554            
555            class PEGASUS_COMMON_LINKAGE StackUnderflow : public Exception
556            {
557            public:
558            
559                static const char MSG[];
560            
561                StackUnderflow() : Exception(MSG) { }
562            };
563            
564 karl  1.20 class PEGASUS_COMMON_LINKAGE QueueUnderflow : public Exception
565            {
566            public:
567            
568                static const char MSG[];
569            
570                QueueUnderflow() : Exception(MSG) { }
571            };
572            
573            
574 mike  1.18 class PEGASUS_COMMON_LINKAGE BadFormat : public Exception
575            {
576            public:
577            
578                static const char MSG[];
579            
580                BadFormat() : Exception(MSG) { }
581            };
582            
583            class PEGASUS_COMMON_LINKAGE BadDateTimeFormat : public Exception
584            {
585            public:
586            
587                static const char MSG[];
588            
589                BadDateTimeFormat() : Exception(MSG) { }
590            };
591            
592            class PEGASUS_COMMON_LINKAGE IncompatibleTypes : public Exception
593            {
594            public:
595 mike  1.18 
596                static const char MSG[];
597            
598                IncompatibleTypes() : Exception(MSG) { }
599            };
600            
601            class PEGASUS_COMMON_LINKAGE BadlyFormedCGIQueryString : public Exception
602            {
603            public:
604            
605                static const char MSG[];
606            
607                BadlyFormedCGIQueryString() : Exception(MSG) { }
608            };
609            
610            class PEGASUS_COMMON_LINKAGE IllformedObjectName : public Exception
611            {
612            public:
613            
614                static const char MSG[];
615            
616 mike  1.18     IllformedObjectName(const String& instanceName)
617            	: Exception(MSG + instanceName) { }
618            };
619            
620            class PEGASUS_COMMON_LINKAGE DynamicLoadFailed : public Exception
621            {
622            public:
623            
624                static const char MSG[];
625            
626                DynamicLoadFailed(const String& libraryName)
627            	: Exception(MSG + libraryName) { }
628            };
629            
630            class PEGASUS_COMMON_LINKAGE DynamicLookupFailed : public Exception
631            {
632            public:
633            
634                static const char MSG[];
635            
636                DynamicLookupFailed(const String& symbolName)
637 mike  1.18 	: Exception(MSG + symbolName) { }
638            };
639            
640            class PEGASUS_COMMON_LINKAGE CannotOpenDirectory : public Exception
641            {
642            public:
643            
644                static const char MSG[];
645            
646                CannotOpenDirectory(const String& path) : Exception(MSG + path) { }
647            };
648            
649            class PEGASUS_COMMON_LINKAGE CorruptFile : public Exception
650            {
651            public:
652            
653                static const char MSG[];
654            
655                CorruptFile(const String& path) : Exception(MSG + path) { }
656            };
657            
658 mike  1.18 PEGASUS_COMMON_LINKAGE void ThrowUnitializedHandle();
659            
660            PEGASUS_NAMESPACE_END
661            
662            #endif /* Pegasus_Exception_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2