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
|
199 mike 1.22
200 ////////////////////////////////////////////////////////////////////////////////
201 //
202 // CIMException
203 //
204 ////////////////////////////////////////////////////////////////////////////////
205
206 static String _makeCIMExceptionMessage(
207 CIMStatusCode code,
208 const char* file,
209 Uint32 line,
210 const String& extraMessage)
211 {
212 String tmp = file;
213 tmp.append("(");
214 char buffer[32];
215 sprintf(buffer, "%d", line);
216 tmp.append(buffer);
217 tmp.append("): ");
218
219 tmp.append(CIMStatusCodeToString(code));
220 mike 1.22 tmp.append(": \"");
221 tmp.append(extraMessage);
222 tmp.append("\"");
223 return tmp;
224 }
225
226 CIMException::CIMException(
227 CIMStatusCode code,
228 const char* file,
229 Uint32 line,
230 const String& extraMessage)
231 : Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)),
232 _code(code)
233 {
234
235 }
236
237 void ThrowUnitializedHandle()
238 {
239 throw UnitializedHandle();
240 }
241 mike 1.22
242 PEGASUS_NAMESPACE_END
|