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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2