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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2