(file) Return to Exception.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2