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 };
|
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
|