1 mike 1.22 //%/////////////////////////////////////////////////////////////////////////////
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.22 //
23 // Author: Mike Brasher (mbrasher@bmc.com)
24 //
|
27 mike 1.22 // Modified By:
28 //
29 //%/////////////////////////////////////////////////////////////////////////////
30
31 #include <cstdio>
32 #include "Exception.h"
33
34 PEGASUS_NAMESPACE_BEGIN
35
36 Exception::Exception(const String& message) : _message(message)
37 {
38
39 }
40
41 Exception::Exception(const char* message) : _message(message)
42 {
43
44 }
45
46 Exception::~Exception()
47 {
48 mike 1.22
49 }
50
51 AssertionFailureException::AssertionFailureException(
52 const char* file,
53 size_t line,
54 const String& message) : Exception(String())
55 {
56 char lineStr[32];
57 sprintf(lineStr, "%d", line);
58
59 _message = file;
60 _message.append("(");
61 _message.append(lineStr);
62 _message.append("): ");
63 _message.append(message);
64 }
65
66 const char OutOfBounds::MSG[] = "out of bounds";
67
68 const char AlreadyExists::MSG[] = "already exists: ";
69 mike 1.22
70 const char NullPointer::MSG[] = "null pointer";
71
72 const char UnitializedHandle::MSG[] = "unitialized handle";
73
74 const char IllegalName::MSG[] = "illegal CIM name";
75
76 const char InvalidPropertyOverride::MSG[] = "invalid property override: ";
77
78 const char InvalidMethodOverride::MSG[] = "invalid method override: ";
79
80 const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";
81
82 const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";
83
84 const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";
85
86 const char BadQualifierType::MSG[] =
87 "CIMType of qualifier different than its declaration: ";
88
89 const char NullType::MSG[] = "type is null";
90 mike 1.22
91 const char AddedReferenceToClass::MSG[] =
92 "attempted to add reference to a non-association class: ";
93
94 const char ClassAlreadyResolved::MSG[] =
95 "attempt to resolve a class that is already resolved: ";
96
97 const char ClassNotResolved::MSG[] =
98 "class is not yet resolved: ";
99
100 const char InstanceAlreadyResolved::MSG[] =
101 "attempted to resolve a instance that is already resolved";
102
103 const char InstantiatedAbstractClass::MSG[] =
104 "attempted to instantiated an abstract class";
105
106 const char NoSuchProperty::MSG[] = "no such property: ";
107
108 const char TruncatedCharacter::MSG[] =
109 "truncated character during conversion from Char16 to char";
110
111 mike 1.22 const char ExpectedReferenceValue::MSG[] =
112 "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "
113 "in this context";
114
115 const char MissingReferenceClassName::MSG[] = "missing reference class name";
116
117 const char IllegalTypeTag::MSG[] = "illegal type tag";
118
119 const char TypeMismatch::MSG[] = "type mismatch";
120
|
203 mike 1.22 ////////////////////////////////////////////////////////////////////////////////
204 //
205 // CIMException
206 //
207 ////////////////////////////////////////////////////////////////////////////////
208
209 static String _makeCIMExceptionMessage(
210 CIMStatusCode code,
211 const char* file,
212 Uint32 line,
213 const String& extraMessage)
214 {
215 String tmp = file;
216 tmp.append("(");
217 char buffer[32];
218 sprintf(buffer, "%d", line);
219 tmp.append(buffer);
220 tmp.append("): ");
221
222 tmp.append(CIMStatusCodeToString(code));
223 tmp.append(": \"");
224 mike 1.22 tmp.append(extraMessage);
225 tmp.append("\"");
226 return tmp;
227 }
228
229 CIMException::CIMException(
230 CIMStatusCode code,
231 const char* file,
232 Uint32 line,
233 const String& extraMessage)
234 : Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)),
235 _code(code)
236 {
237
238 }
239
240 void ThrowUnitializedHandle()
241 {
242 throw UnitializedHandle();
243 }
244
245 mike 1.22 PEGASUS_NAMESPACE_END
|