(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            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #include <cstdio>
 35            #include "Exception.h"
 36 kumpf 1.59 #include <Pegasus/Common/ExceptionRep.h>
 37 kumpf 1.53 #include <Pegasus/Common/CIMExceptionRep.h>
 38 kumpf 1.33 #include "Tracer.h"
 39 mike  1.81.2.1 #include "Backtrace.h"
 40 mike  1.22     
 41 mike  1.81.2.4 #ifdef PEGASUS_BACKTRACE
 42 mike  1.81.2.2 # undef PEGASUS_BACKTRACE
 43                # define PEGASUS_BACKTRACE /* */
 44                #endif
 45                
 46 mike  1.22     PEGASUS_NAMESPACE_BEGIN
 47                
 48 kumpf 1.59     Exception::Exception(const String& message)
 49                {
 50 mike  1.81.2.1     PEGASUS_BACKTRACE;
 51 kumpf 1.59         _rep = new ExceptionRep();
 52                    _rep->message = message;
 53 kumpf 1.75         _rep->contentLanguages.clear();
 54 kumpf 1.59     }
 55                
 56                Exception::Exception(const Exception& exception)
 57                {
 58 mike  1.81.2.1     PEGASUS_BACKTRACE;
 59 kumpf 1.59         _rep = new ExceptionRep();
 60                    _rep->message = exception._rep->message;
 61 kumpf 1.80         _rep->contentLanguages = exception._rep->contentLanguages;
 62 chuck 1.64     }
 63                
 64                Exception::Exception(const MessageLoaderParms& msgParms)
 65                {
 66 mike  1.81.2.1     PEGASUS_BACKTRACE;
 67 chuck 1.64         _rep = new ExceptionRep();
 68                    _rep->message = MessageLoader::getMessage(
 69 kumpf 1.80             const_cast<MessageLoaderParms &>(msgParms));
 70 karl  1.78         // Must be after MessageLoader::getMessage call
 71 chuck 1.64         _rep->contentLanguages = msgParms.contentlanguages;
 72 kumpf 1.59     }
 73                
 74                Exception::Exception()
 75 chip  1.39     {
 76 mike  1.81.2.1     PEGASUS_BACKTRACE;
 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 kumpf   1.76     const ContentLanguageList& Exception::getContentLanguages() const
 91 chuck   1.64     {
 92 kumpf   1.80         return _rep->contentLanguages;
 93 karl    1.78     }
 94 chuck   1.64     
 95 kumpf   1.76     void Exception::setContentLanguages(const ContentLanguageList& langs)
 96 chuck   1.64     {
 97 kumpf   1.80         _rep->contentLanguages = langs;
 98 kumpf   1.54     }
 99 mike    1.22     
100 chuck   1.64     IndexOutOfBoundsException::IndexOutOfBoundsException()
101 kumpf   1.80         : Exception(MessageLoaderParms(
102                            "Common.Exception.INDEX_OUT_OF_BOUNDS_EXCEPTION",
103                            "index out of bounds"))
104 chuck   1.64     {
105                  }
106                  
107 kumpf   1.55     AlreadyExistsException::AlreadyExistsException(const String& message)
108 kumpf   1.80         : Exception(MessageLoaderParms(
109                            "Common.Exception.ALREADY_EXISTS_EXCEPTION",
110                            "already exists: $0",
111                            message))
112 chuck   1.64     {
113                  }
114                  
115 chuck   1.65     AlreadyExistsException::AlreadyExistsException(MessageLoaderParms& msgParms)
116 kumpf   1.80         : Exception(MessageLoaderParms(
117                            "Common.Exception.ALREADY_EXISTS_EXCEPTION",
118                            "already exists: "))
119 kumpf   1.54     {
120 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
121 kumpf   1.54     }
122 mike    1.22     
123 chuck   1.64     InvalidNameException::InvalidNameException(const String& message)
124 kumpf   1.80         : Exception(MessageLoaderParms(
125                            "Common.Exception.INVALID_NAME_EXCEPTION",
126                            "invalid CIM name: $0",
127                            message))
128 chuck   1.64     {
129                  }
130                  
131 chuck   1.65     InvalidNameException::InvalidNameException(MessageLoaderParms& msgParms)
132 kumpf   1.80         : Exception(MessageLoaderParms(
133                            "Common.Exception.INVALID_NAME_EXCEPTION",
134                            "invalid CIM name: "))
135 chuck   1.64     {
136 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
137 chuck   1.64     }
138                  
139 kumpf   1.54     InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
140 kumpf   1.80         : Exception(MessageLoaderParms(
141                            "Common.Exception.INVALID_NAMESACE_NAME_EXCEPTION",
142                            "invalid CIM namespace name: $0",
143                            name))
144 kumpf   1.54     {
145                  }
146 chuck   1.65     
147 kumpf   1.80     InvalidNamespaceNameException::InvalidNamespaceNameException(
148                      MessageLoaderParms& msgParms)
149                      : Exception(MessageLoaderParms(
150                            "Common.Exception.INVALID_NAMESPACE_NAME_EXCEPTION",
151                            "invalid CIM namespace name: "))
152 chuck   1.64     {
153 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
154 chuck   1.64     }
155                  
156                  UninitializedObjectException::UninitializedObjectException()
157 kumpf   1.80         : Exception(MessageLoaderParms(
158                            "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
159                            "uninitialized object"))
160 chuck   1.64     {
161                  }
162                  
163 kumpf   1.55     TypeMismatchException::TypeMismatchException()
164 kumpf   1.80         : Exception(MessageLoaderParms(
165                            "Common.Exception.TYPE_MISMATCH_EXCEPTION",
166                            "type mismatch"))
167 chuck   1.64     {
168                  }
169                  
170 marek   1.69     TypeMismatchException::TypeMismatchException(const String& message)
171 kumpf   1.80         : Exception(MessageLoaderParms(
172                            "Common.Exception.TYPE_MISMATCH_EXCEPTION",
173                            "type mismatch: $0",message))
174 marek   1.69     {
175                  
176                  }
177                  
178                  TypeMismatchException::TypeMismatchException(MessageLoaderParms& msgParms)
179 kumpf   1.80         : Exception(MessageLoaderParms(
180                            "Common.Exception.TYPE_MISMATCH_EXCEPTION",
181                            "type mismatch: "))
182 marek   1.69     {
183                      _rep->message.append(MessageLoader::getMessage(msgParms));
184                  }
185                  
186 chuck   1.64     DynamicCastFailedException::DynamicCastFailedException()
187 kumpf   1.80         : Exception(MessageLoaderParms(
188                            "Common.Exception.DYNAMIC_CAST_FAILED_EXCEPTION",
189                            "dynamic cast failed"))
190 chuck   1.64     {
191                  }
192                  
193 kumpf   1.55     InvalidDateTimeFormatException::InvalidDateTimeFormatException()
194 kumpf   1.80         : Exception(MessageLoaderParms(
195                            "Common.Exception.INVALID_DATETIME_FORMAT_EXCEPTION",
196                            "invalid datetime format"))
197 kumpf   1.54     {
198                  }
199 mike    1.22     
200 kumpf   1.80     MalformedObjectNameException::MalformedObjectNameException(
201                      const String& message)
202                      : Exception(MessageLoaderParms(
203                            "Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
204                            "malformed object name: $0",
205                            message))
206 chuck   1.64     {
207                  }
208                  
209 kumpf   1.54     MalformedObjectNameException::MalformedObjectNameException(
210 kumpf   1.80         MessageLoaderParms& msgParms)
211                      : Exception(MessageLoaderParms(
212                            "Common.Exception.MALFORMED_OBJECT_NAME_EXCEPTION",
213                            "malformed object name: "))
214 kumpf   1.54     {
215 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
216 kumpf   1.54     }
217 mike    1.23     
218 chuck   1.64     BindFailedException::BindFailedException(const String& message)
219 kumpf   1.80         : Exception(MessageLoaderParms(
220                            "Common.Exception.BIND_FAILED_EXCEPTION",
221                            "Bind failed: $0",
222                            message))
223 chuck   1.64     {
224                  }
225                  
226 chuck   1.65     BindFailedException::BindFailedException(MessageLoaderParms& msgParms)
227 kumpf   1.80         : Exception(MessageLoaderParms(
228                            "Common.Exception.BIND_FAILED_EXCEPTION",
229                            "Bind failed: "))
230 chuck   1.64     {
231 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
232 chuck   1.64     }
233                  
234                  InvalidLocatorException::InvalidLocatorException(const String& message)
235 kumpf   1.80         : Exception(MessageLoaderParms(
236                            "Common.Exception.INVALID_LOCATOR_EXCEPTION",
237                            "Invalid locator: $0",
238                            message))
239 chuck   1.64     {
240                  }
241                  
242 chuck   1.65     InvalidLocatorException::InvalidLocatorException(MessageLoaderParms& msgParms)
243 kumpf   1.80         : Exception(MessageLoaderParms(
244                            "Common.Exception.INVALID_LOCATOR_EXCEPTION",
245                            "Invalid locator: "))
246 kumpf   1.54     {
247 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
248 kumpf   1.54     }
249 mike    1.23     
250 chuck   1.64     CannotCreateSocketException::CannotCreateSocketException()
251 kumpf   1.80         : Exception(MessageLoaderParms(
252                            "Common.Exception.CANNOT_CREATE_SOCKET_EXCEPTION",
253                            "Cannot create socket"))
254 chuck   1.64     {
255                  }
256                  
257 chuck   1.65     
258                  CannotConnectException::CannotConnectException(const String& message)//???
259 kumpf   1.63         : Exception(message)
260 kumpf   1.54     {
261                  }
262 chuck   1.65     
263                  
264                  CannotConnectException::CannotConnectException(MessageLoaderParms& msgParms)
265 chuck   1.64         : Exception(msgParms)
266                  {
267                  }
268 mike    1.23     
269 kumpf   1.54     AlreadyConnectedException::AlreadyConnectedException()
270 kumpf   1.80         : Exception(MessageLoaderParms(
271                            "Common.Exception.ALREADY_CONNECTED_EXCEPTION",
272                            "already connected"))
273 kumpf   1.54     {
274                  }
275 mike    1.23     
276 chuck   1.64     
277 kumpf   1.54     NotConnectedException::NotConnectedException()
278 kumpf   1.80         : Exception(MessageLoaderParms(
279                            "Common.Exception.NOT_CONNECTED_EXCEPTION",
280                            "not connected"))
281 kumpf   1.54     {
282                  }
283 kumpf   1.26     
284 chuck   1.64     ConnectionTimeoutException::ConnectionTimeoutException()
285 kumpf   1.80         : Exception(MessageLoaderParms(
286                            "Common.Exception.CONNECTION_TIMEOUT_EXCEPTION",
287                            "connection timed out"))
288 chuck   1.64     {
289                  }
290                  
291 kumpf   1.54     SSLException::SSLException(const String& message)
292 kumpf   1.80         : Exception(MessageLoaderParms(
293                            "Common.Exception.SSL_EXCEPTION",
294                            "SSL Exception: $0" ,
295                            message))
296 chuck   1.64     {
297                  }
298                  
299 chuck   1.65     SSLException::SSLException(MessageLoaderParms& msgParms)
300 kumpf   1.80         : Exception(MessageLoaderParms(
301                            "Common.Exception.SSL_EXCEPTION",
302                            "SSL Exception: " ))
303 chuck   1.64     {
304 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
305 chuck   1.64     }
306                  
307 kumpf   1.62     DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
308 kumpf   1.80         : Exception(MessageLoaderParms(
309                            "Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
310                            "DateTime is out of range : $0" ,
311                            message))
312 kumpf   1.62     {
313                  }
314 kumpf   1.26     
315 kumpf   1.80     DateTimeOutOfRangeException::DateTimeOutOfRangeException(
316                      MessageLoaderParms& msgParms)
317                      : Exception(MessageLoaderParms(
318                            "Common.Exception.DATETIME_OUT_OF_RANGE_EXCEPTION",
319                            "DateTime is out of range : " ))
320 chuck   1.64     {
321 kumpf   1.80         _rep->message.append(MessageLoader::getMessage(msgParms));
322 chuck   1.64     }
323 chuck   1.65     
324 mike    1.22     ////////////////////////////////////////////////////////////////////////////////
325                  //
326                  // CIMException
327                  //
328                  ////////////////////////////////////////////////////////////////////////////////
329                  
330 chuck   1.64     // l10n - note - use this when you have an exception with no
331                  // detail message, or one with an untranslated detail message
332                  // The pegasus message associated with code will be translated.
333 kumpf   1.53     CIMException::CIMException(
334 kumpf   1.29         CIMStatusCode code,
335 kumpf   1.37         const String& message)
336 kumpf   1.61         : Exception()
337 kumpf   1.29     {
338 kumpf   1.59         CIMExceptionRep * tmp = new CIMExceptionRep ();
339                      tmp->message = message;
340                      tmp->code = code;
341                      tmp->file = "";
342                      tmp->line = 0;
343 kumpf   1.75         tmp->contentLanguages.clear();
344 karl    1.78         tmp->cimMessage = String::EMPTY;
345                      _rep = tmp;
346                  }
347                  
348                  
349 kumpf   1.80     // l10n - note - use this when you have an exception
350 karl    1.78     // an untranslated detail message and an attached CIM_Error
351                  // The pegasus message associated with code will be translated.
352                  CIMException::CIMException(
353                      CIMStatusCode code,
354                      const String& message,
355                      const CIMInstance& instance)
356                      : Exception()
357                  {
358                      CIMExceptionRep * tmp = new CIMExceptionRep ();
359                      tmp->message = message;
360                      tmp->code = code;
361                      tmp->file = "";
362                      tmp->errors.append(instance);
363                      tmp->line = 0;
364                      tmp->contentLanguages.clear();
365 kumpf   1.80         tmp->cimMessage = String::EMPTY;
366 chuck   1.64         _rep = tmp;
367                  }
368                  
369 kumpf   1.80     // l10n - note - use this when you have an exception
370 karl    1.78     // an untranslated detail message and an attached CIM_Error
371                  // array
372                  // The pegasus message associated with code will be translated.
373                  CIMException::CIMException(
374                      CIMStatusCode code,
375                      const String& message,
376                      const Array<CIMInstance>& instances)
377                      : Exception()
378                  {
379                      CIMExceptionRep * tmp = new CIMExceptionRep ();
380                      tmp->message = message;
381                      tmp->code = code;
382                      tmp->file = "";
383                      tmp->errors.appendArray(instances);
384                      tmp->line = 0;
385                      tmp->contentLanguages.clear();
386 kumpf   1.80         tmp->cimMessage = String::EMPTY;
387 karl    1.78         _rep = tmp;
388                  }
389 chuck   1.64     // l10n - note use this when you have an exception with a translated
390                  // detail message
391                  CIMException::CIMException(
392                      CIMStatusCode code,
393                      const MessageLoaderParms& msgParms)
394                      : Exception()
395                  {
396 kumpf   1.80         CIMExceptionRep* tmp = new CIMExceptionRep();
397 chuck   1.64         tmp->message = MessageLoader::getMessage(
398 kumpf   1.80             const_cast<MessageLoaderParms &>(msgParms));
399 chuck   1.64         // Must be after MessageLoader::getMessage call
400 karl    1.78         tmp->contentLanguages = msgParms.contentlanguages;
401                      tmp->cimMessage = String::EMPTY;
402                      tmp->code = code;
403                      tmp->file = "";
404                      tmp->line = 0;
405                      _rep = tmp;
406                  }
407                  
408                  CIMException::CIMException(
409                      CIMStatusCode code,
410                      const MessageLoaderParms& msgParms,
411                      const CIMInstance& instance)
412                      : Exception()
413                  {
414 kumpf   1.80         CIMExceptionRep* tmp = new CIMExceptionRep();
415 karl    1.78         tmp->message = MessageLoader::getMessage(
416 kumpf   1.80             const_cast<MessageLoaderParms &>(msgParms));
417 karl    1.78         // Must be after MessageLoader::getMessage call
418 kumpf   1.80         tmp->contentLanguages = msgParms.contentlanguages;
419 chuck   1.64         tmp->cimMessage = String::EMPTY;
420 karl    1.78         tmp->errors.append(instance);
421 chuck   1.64         tmp->code = code;
422                      tmp->file = "";
423                      tmp->line = 0;
424 kumpf   1.59         _rep = tmp;
425 kumpf   1.29     }
426                  
427 karl    1.78     CIMException::CIMException(
428                      CIMStatusCode code,
429                      const MessageLoaderParms& msgParms,
430                      const Array<CIMInstance>& instances)
431                      : Exception()
432                  {
433 kumpf   1.80         CIMExceptionRep* tmp = new CIMExceptionRep();
434 karl    1.78         tmp->message = MessageLoader::getMessage(
435 kumpf   1.80             const_cast<MessageLoaderParms &>(msgParms));
436 karl    1.78         // Must be after MessageLoader::getMessage call
437 kumpf   1.80         tmp->contentLanguages = msgParms.contentlanguages;
438 karl    1.78         tmp->cimMessage = String::EMPTY;
439                      tmp->errors.appendArray(instances);
440                      tmp->code = code;
441                      tmp->file = "";
442                      tmp->line = 0;
443                      _rep = tmp;
444                  }
445 kumpf   1.53     CIMException::CIMException(const CIMException & cimException)
446 kumpf   1.61         : Exception()
447 kumpf   1.53     {
448 kumpf   1.80         CIMExceptionRep* tmp = new CIMExceptionRep();
449                      CIMExceptionRep* rep;
450 kumpf   1.59         rep = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
451                      tmp->message = rep->message;
452 kumpf   1.80         tmp->contentLanguages = rep->contentLanguages;
453                      tmp->cimMessage = rep->cimMessage;
454 kumpf   1.59         tmp->code = rep->code;
455                      tmp->file = rep->file;
456                      tmp->line = rep->line;
457 karl    1.78         tmp->errors = rep->errors;
458 kumpf   1.59         _rep = tmp;
459 mike    1.22     }
460                  
461 kumpf   1.53     CIMException& CIMException::operator=(const CIMException & cimException)
462 mike    1.22     {
463 kumpf   1.72         if (&cimException != this)
464                      {
465                          CIMExceptionRep* left;
466                          CIMExceptionRep* right;
467                          left = reinterpret_cast<CIMExceptionRep*>(this->_rep);
468                          right = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
469                          left->message = right->message;
470 kumpf   1.80             left->contentLanguages = right->contentLanguages;
471                          left->cimMessage = right->cimMessage;
472 kumpf   1.72             left->code = right->code;
473                          left->file = right->file;
474                          left->line = right->line;
475 kumpf   1.80             left->errors = right->errors;
476 kumpf   1.72         }
477 kumpf   1.53         return *this;
478 kumpf   1.32     }
479                  
480 kumpf   1.53     CIMException::~CIMException()
481 kumpf   1.37     {
482                  }
483                  
484 karl    1.78     Uint32 CIMException::getErrorCount() const
485                  {
486                      return reinterpret_cast<CIMExceptionRep*>(_rep)->errors.size();
487                  }
488                  /**************
489                  CIMInstance CIMException::getError(Uint32 index)
490                  {
491                      return reinterpret_cast<CIMExceptionRep*>(_rep)->errors[index];
492                  }
493                  ***************/
494                  
495                  CIMConstInstance CIMException::getError(Uint32 index) const
496                  {
497                      return reinterpret_cast<CIMExceptionRep*>(_rep)->errors[index];
498                  }
499                  
500                  void CIMException::addError(const CIMInstance& instance)
501                  {
502 mike    1.79         reinterpret_cast<CIMExceptionRep*>(_rep)->errors.append(instance);
503 karl    1.78     }
504                  
505 kumpf   1.53     CIMStatusCode CIMException::getCode() const
506 kumpf   1.37     {
507 kumpf   1.59         CIMExceptionRep* rep;
508                      rep = reinterpret_cast<CIMExceptionRep*>(_rep);
509                      return rep->code;
510 mike    1.22     }
511                  
512                  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2