1 karl 1.68 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.22 //
|
3 karl 1.68 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.22 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 chip 1.39 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.22 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 karl 1.68 //
|
15 chip 1.39 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 chip 1.39 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.22 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Mike Brasher (mbrasher@bmc.com)
27 //
|
28 kumpf 1.52 // Modified By: Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
29 // Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
|
30 kumpf 1.43 // Carol Ann Krug Graves, Hewlett-Packard Company
31 // (carolann_graves@hp.com)
|
32 kumpf 1.52 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
33 kumpf 1.62 // Sushma Fernandes , Hewlett-Packard Company
34 // (sushma_fernandes@hp.com)
|
35 a.arora 1.71 // Amit K Arora, IBM (amita@in.ibm.com) for bug# 1593
|
36 mike 1.22 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #include <cstdio>
40 #include "Exception.h"
|
41 kumpf 1.59 #include <Pegasus/Common/ExceptionRep.h>
|
42 kumpf 1.53 #include <Pegasus/Common/CIMExceptionRep.h>
|
43 kumpf 1.33 #include "Tracer.h"
|
44 mike 1.22
45 PEGASUS_NAMESPACE_BEGIN
46
|
47 kumpf 1.59 Exception::Exception(const String& message)
48 {
49 _rep = new ExceptionRep();
50 _rep->message = message;
|
51 chuck 1.64 _rep->contentLanguages = ContentLanguages::EMPTY; // l10n
|
52 kumpf 1.59 }
53
54 Exception::Exception(const Exception& exception)
55 {
56 _rep = new ExceptionRep();
57 _rep->message = exception._rep->message;
|
58 chuck 1.64 _rep->contentLanguages = exception._rep->contentLanguages; // l10n
59 }
60
61 // l10n
62 Exception::Exception(const MessageLoaderParms& msgParms)
63 {
64 _rep = new ExceptionRep();
65 _rep->message = MessageLoader::getMessage(
66 const_cast<MessageLoaderParms &>(msgParms));
67 // Must be after MessageLoader::getMessage call
68 _rep->contentLanguages = msgParms.contentlanguages;
|
69 kumpf 1.59 }
70
71 Exception::Exception()
|
72 chip 1.39 {
|
73 a.arora 1.71 _rep = NULL;
|
74 mike 1.22 }
75
|
76 kumpf 1.54 Exception::~Exception()
|
77 mike 1.22 {
|
78 kumpf 1.59 delete _rep;
|
79 mike 1.22 }
80
|
81 kumpf 1.54 const String& Exception::getMessage() const
|
82 mike 1.22 {
|
83 kumpf 1.59 return _rep->message;
|
84 mike 1.22 }
85
|
86 chuck 1.64 // l10n
87 const ContentLanguages& Exception::getContentLanguages() const
88 {
89 return _rep->contentLanguages;
90 }
91
92 // l10n
93 void Exception::setContentLanguages(const ContentLanguages& langs)
94 {
95 _rep->contentLanguages = langs;
96 }
97
|
98 chuck 1.65 /*
|
99 kumpf 1.55 IndexOutOfBoundsException::IndexOutOfBoundsException()
100 : Exception("index out of bounds")
|
101 kumpf 1.54 {
102 }
|
103 chuck 1.65 */
|
104 mike 1.22
|
105 chuck 1.64 IndexOutOfBoundsException::IndexOutOfBoundsException()
|
106 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INDEX_OUT_OF_BOUNDS_EXCEPTION","index out of bounds"))
|
107 chuck 1.64 {
108 }
109
|
110 chuck 1.65 /*
|
111 kumpf 1.55 AlreadyExistsException::AlreadyExistsException(const String& message)
|
112 kumpf 1.54 : Exception("already exists: " + message)
113 {
114 }
|
115 chuck 1.65 */
|
116 mike 1.22
|
117 chuck 1.64 AlreadyExistsException::AlreadyExistsException(const String& message)
|
118 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.ALREADY_EXISTS_EXCEPTION",
|
119 chuck 1.65 "already exists: $0",
|
120 chuck 1.64 message))
121 {
122 }
123
|
124 chuck 1.65 AlreadyExistsException::AlreadyExistsException(MessageLoaderParms& msgParms)
|
125 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.ALREADY_EXISTS_EXCEPTION",
|
126 chuck 1.64 "already exists: "))
127 {
|
128 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
129 chuck 1.64 }
130
|
131 chuck 1.65 /*
|
132 kumpf 1.54 InvalidNameException::InvalidNameException(const String& name)
133 : Exception("invalid CIM name: " + name)
134 {
135 }
|
136 chuck 1.65 */
|
137 mike 1.22
|
138 chuck 1.64 InvalidNameException::InvalidNameException(const String& message)
|
139 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INVALID_NAME_EXCEPTION",
|
140 chuck 1.65 "invalid CIM name: $0",
|
141 chuck 1.64 message))
142 {
143 }
144
|
145 chuck 1.65 InvalidNameException::InvalidNameException(MessageLoaderParms& msgParms)
|
146 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INVALID_NAME_EXCEPTION",
|
147 chuck 1.64 "invalid CIM name: "))
148 {
|
149 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
150 chuck 1.64 }
151
|
152 chuck 1.65 /*
|
153 kumpf 1.54 InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
154 : Exception("invalid CIM namespace name: " + name)
155 {
156 }
|
157 chuck 1.65 */
158
|
159 kumpf 1.44
|
160 chuck 1.64 InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
|
161 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INVALID_NAMESACE_NAME_EXCEPTION",
|
162 chuck 1.65 "invalid CIM namespace name: $0",
|
163 chuck 1.64 name))
164 {
165 }
166
|
167 chuck 1.65 InvalidNamespaceNameException::InvalidNamespaceNameException(MessageLoaderParms& msgParms)
|
168 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INVALID_NAMESPACE_NAME_EXCEPTION",
|
169 chuck 1.64 "invalid CIM namespace name: "))
170 {
|
171 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
172 chuck 1.64 }
173
|
174 chuck 1.65 /*
|
175 kumpf 1.55 UninitializedObjectException::UninitializedObjectException()
|
176 kumpf 1.54 : Exception("uninitialized object")
177 {
178 }
|
179 chuck 1.65 */
|
180 mike 1.22
|
181 chuck 1.64 UninitializedObjectException::UninitializedObjectException()
|
182 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
|
183 chuck 1.64 "uninitialized object"))
184 {
185 }
186
|
187 chuck 1.65 /*
|
188 kumpf 1.55 TypeMismatchException::TypeMismatchException()
|
189 kumpf 1.54 : Exception("type mismatch")
190 {
191 }
|
192 chuck 1.65 */
|
193 mike 1.22
|
194 chuck 1.64 TypeMismatchException::TypeMismatchException()
|
195 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.TYPE_MISMATCH_EXCEPTION",
|
196 chuck 1.64 "type mismatch"))
197 {
198 }
199
|
200 marek 1.69 TypeMismatchException::TypeMismatchException(const String& message)
201 : Exception(MessageLoaderParms("Common.Exception.TYPE_MISMATCH_EXCEPTION",
202 "type mismatch: $0",message))
203 {
204
205 }
206
207 TypeMismatchException::TypeMismatchException(MessageLoaderParms& msgParms)
208 : Exception(MessageLoaderParms("Common.Exception.TYPE_MISMATCH_EXCEPTION",
209 "type mismatch: "))
210 {
211 _rep->message.append(MessageLoader::getMessage(msgParms));
212 }
213
|
214 chuck 1.65 /*
|
215 kumpf 1.55 DynamicCastFailedException::DynamicCastFailedException()
|
216 kumpf 1.54 : Exception("dynamic cast failed")
217 {
218 }
|
219 chuck 1.65 */
|
220 mike 1.24
|
221 chuck 1.64 DynamicCastFailedException::DynamicCastFailedException()
|
222 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.DYNAMIC_CAST_FAILED_EXCEPTION",
|
223 chuck 1.64 "dynamic cast failed"))
224 {
225 }
226
|
227 chuck 1.65 /*
|
228 kumpf 1.55 InvalidDateTimeFormatException::InvalidDateTimeFormatException()
229 : Exception("invalid datetime format")
|
230 kumpf 1.54 {
231 }
|
232 chuck 1.65 */
|
233 mike 1.22
|
234 chuck 1.64 InvalidDateTimeFormatException::InvalidDateTimeFormatException()
|
235 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INVALID_DATETIME_FORMAT_EXCEPTION",
|
236 chuck 1.64 "invalid datetime format"))
237 {
238 }
239
|
240 chuck 1.65 /*
|
241 kumpf 1.54 MalformedObjectNameException::MalformedObjectNameException(
242 const String& objectName)
243 : Exception("malformed object name: " + objectName)
244 {
245 }
|
246 chuck 1.65 */
|
247 mike 1.22
|
248 chuck 1.64 MalformedObjectNameException::MalformedObjectNameException(const String& message)
|
249 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
|
250 chuck 1.65 "malformed object name: $0",
|
251 chuck 1.64 message))
252 {
253 }
254
|
255 chuck 1.65 MalformedObjectNameException::MalformedObjectNameException(MessageLoaderParms& msgParms)
|
256 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
|
257 chuck 1.64 "malformed object name: "))
258 {
|
259 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
260 chuck 1.64 }
261
|
262 chuck 1.65 /*
|
263 kumpf 1.54 BindFailedException::BindFailedException(const String& message)
264 : Exception("Bind failed: " + message)
265 {
266 }
|
267 chuck 1.65 */
|
268 mike 1.23
|
269 chuck 1.64 BindFailedException::BindFailedException(const String& message)
|
270 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.BIND_FAILED_EXCEPTION",
|
271 chuck 1.65 "Bind failed: $0",
|
272 chuck 1.64 message))
273 {
274 }
275
|
276 chuck 1.65 BindFailedException::BindFailedException(MessageLoaderParms& msgParms)
|
277 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.BIND_FAILED_EXCEPTION",
|
278 chuck 1.64 "Bind failed: "))
279 {
|
280 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
281 chuck 1.64 }
282
|
283 chuck 1.65 /*
|
284 kumpf 1.54 InvalidLocatorException::InvalidLocatorException(const String& locator)
285 : Exception("Invalid locator: " + locator)
286 {
287 }
|
288 chuck 1.65 */
|
289 mike 1.23
|
290 chuck 1.64 InvalidLocatorException::InvalidLocatorException(const String& message)
|
291 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INVALID_LOCATOR_EXCEPTION",
|
292 chuck 1.65 "Invalid locator: $0",
|
293 chuck 1.64 message))
294 {
295 }
296
|
297 chuck 1.65 InvalidLocatorException::InvalidLocatorException(MessageLoaderParms& msgParms)
|
298 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.INVALID_LOCATOR_EXCEPTION",
|
299 chuck 1.64 "Invalid locator: "))
300 {
|
301 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
302 chuck 1.64 }
303
|
304 chuck 1.65 /*
|
305 kumpf 1.54 CannotCreateSocketException::CannotCreateSocketException()
306 : Exception("Cannot create socket")
307 {
308 }
|
309 chuck 1.65 */
|
310 mike 1.23
|
311 chuck 1.64 CannotCreateSocketException::CannotCreateSocketException()
|
312 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.CANNOT_CREATE_SOCKET_EXCEPTION",
|
313 chuck 1.64 "Cannot create socket"))
314 {
315 }
316
|
317 chuck 1.65
318 CannotConnectException::CannotConnectException(const String& message)//???
|
319 kumpf 1.63 : Exception(message)
|
320 kumpf 1.54 {
321 }
|
322 chuck 1.65
323
324 CannotConnectException::CannotConnectException(MessageLoaderParms& msgParms)
|
325 chuck 1.64 : Exception(msgParms)
326 {
327 }
|
328 mike 1.23
|
329 chuck 1.65 /*
|
330 kumpf 1.54 AlreadyConnectedException::AlreadyConnectedException()
331 : Exception("already connected")
332 {
333 }
|
334 chuck 1.65 */
|
335 mike 1.23
|
336 chuck 1.64 AlreadyConnectedException::AlreadyConnectedException()
|
337 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.ALREADY_CONNECTED_EXCEPTION",
|
338 chuck 1.64 "already connected"))
339 {
340 }
341
|
342 chuck 1.65 /*
|
343 kumpf 1.54 NotConnectedException::NotConnectedException()
344 : Exception("not connected")
345 {
346 }
|
347 chuck 1.65 */
|
348 mike 1.22
|
349 chuck 1.64 NotConnectedException::NotConnectedException()
|
350 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.NOT_CONNECTED_EXCEPTION",
|
351 chuck 1.64 "not connected"))
352 {
353 }
354
|
355 chuck 1.65 /*
|
356 kumpf 1.54 ConnectionTimeoutException::ConnectionTimeoutException()
357 : Exception("connection timed out")
358 {
359 }
|
360 chuck 1.65 */
|
361 kumpf 1.26
|
362 chuck 1.64 ConnectionTimeoutException::ConnectionTimeoutException()
|
363 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.CONNECTION_TIMEOUT_EXCEPTION",
|
364 chuck 1.64 "connection timed out"))
365 {
366 }
367
|
368 chuck 1.65 /*
|
369 kumpf 1.54 SSLException::SSLException(const String& message)
370 : Exception("SSL Exception: " + message)
371 {
372 }
|
373 chuck 1.65 */
|
374 kumpf 1.40
|
375 chuck 1.64 SSLException::SSLException(const String& message)
|
376 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.SSL_EXCEPTION",
|
377 chuck 1.65 "SSL Exception: $0" ,
|
378 chuck 1.64 message))
379 {
380 }
381
|
382 chuck 1.65 SSLException::SSLException(MessageLoaderParms& msgParms)
|
383 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.SSL_EXCEPTION",
|
384 chuck 1.64 "SSL Exception: " ))
385 {
|
386 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
387 chuck 1.64 }
388
|
389 chuck 1.65 /*
|
390 kumpf 1.62 DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
391 : Exception("DateTime is out of range : " + message)
392 {
393 }
|
394 chuck 1.65 */
|
395 kumpf 1.26
|
396 chuck 1.64 DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
|
397 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
|
398 chuck 1.65 "DateTime is out of range : $0" ,
|
399 chuck 1.64 message))
400 {
401 }
402
|
403 chuck 1.65 DateTimeOutOfRangeException::DateTimeOutOfRangeException(MessageLoaderParms& msgParms)
|
404 humberto 1.67 : Exception(MessageLoaderParms("Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
|
405 chuck 1.64 "DateTime is out of range : " ))
406 {
|
407 chuck 1.65 _rep->message.append(MessageLoader::getMessage(msgParms));
|
408 chuck 1.64 }
|
409 chuck 1.65
|
410 chuck 1.64
|
411 mike 1.22 ////////////////////////////////////////////////////////////////////////////////
412 //
413 // CIMException
414 //
415 ////////////////////////////////////////////////////////////////////////////////
416
|
417 chuck 1.64 // l10n - note - use this when you have an exception with no
418 // detail message, or one with an untranslated detail message
419 // The pegasus message associated with code will be translated.
|
420 kumpf 1.53 CIMException::CIMException(
|
421 kumpf 1.29 CIMStatusCode code,
|
422 kumpf 1.37 const String& message)
|
423 kumpf 1.61 : Exception()
|
424 kumpf 1.29 {
|
425 kumpf 1.59 CIMExceptionRep * tmp = new CIMExceptionRep ();
426 tmp->message = message;
427 tmp->code = code;
428 tmp->file = "";
429 tmp->line = 0;
|
430 chuck 1.64 tmp->contentLanguages = ContentLanguages::EMPTY;
431 tmp->cimMessage = String::EMPTY;
432 _rep = tmp;
433 }
434
435 // l10n - note use this when you have an exception with a translated
436 // detail message
437 // l10n
438 CIMException::CIMException(
439 CIMStatusCode code,
440 const MessageLoaderParms& msgParms)
441 : Exception()
442 {
443 CIMExceptionRep * tmp = new CIMExceptionRep ();
444 tmp->message = MessageLoader::getMessage(
445 const_cast<MessageLoaderParms &>(msgParms));
446 // Must be after MessageLoader::getMessage call
447 tmp->contentLanguages = msgParms.contentlanguages;
448 tmp->cimMessage = String::EMPTY;
449 tmp->code = code;
450 tmp->file = "";
451 chuck 1.64 tmp->line = 0;
|
452 kumpf 1.59 _rep = tmp;
|
453 kumpf 1.29 }
454
|
455 kumpf 1.53 CIMException::CIMException(const CIMException & cimException)
|
456 kumpf 1.61 : Exception()
|
457 kumpf 1.53 {
|
458 kumpf 1.59 CIMExceptionRep * tmp = new CIMExceptionRep ();
459 CIMExceptionRep * rep;
460 rep = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
461 tmp->message = rep->message;
|
462 chuck 1.64 tmp->contentLanguages = rep->contentLanguages; // l10n
463 tmp->cimMessage = rep->cimMessage; // l10n
|
464 kumpf 1.59 tmp->code = rep->code;
465 tmp->file = rep->file;
466 tmp->line = rep->line;
467 _rep = tmp;
|
468 mike 1.22 }
469
|
470 kumpf 1.53 CIMException& CIMException::operator=(const CIMException & cimException)
|
471 mike 1.22 {
|
472 kumpf 1.72 if (&cimException != this)
473 {
474 CIMExceptionRep* left;
475 CIMExceptionRep* right;
476 left = reinterpret_cast<CIMExceptionRep*>(this->_rep);
477 right = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
478 left->message = right->message;
479 left->contentLanguages = right->contentLanguages; // l10n
480 left->cimMessage = right->cimMessage; // l10n
481 left->code = right->code;
482 left->file = right->file;
483 left->line = right->line;
484 }
|
485 kumpf 1.53 return *this;
|
486 kumpf 1.32 }
487
|
488 kumpf 1.53 CIMException::~CIMException()
|
489 kumpf 1.37 {
490 }
491
|
492 kumpf 1.53 CIMStatusCode CIMException::getCode() const
|
493 kumpf 1.37 {
|
494 kumpf 1.59 CIMExceptionRep* rep;
495 rep = reinterpret_cast<CIMExceptionRep*>(_rep);
496 return rep->code;
|
497 mike 1.22 }
498
499 PEGASUS_NAMESPACE_END
|