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