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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2