(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 chuck 1.64 //  
 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 chuck 1.64     _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 chuck 1.64     _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 chuck 1.64 // 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            // l10n TODO - finish the commented out constructors below 
 95 chuck 1.65 /*
 96 kumpf 1.55 IndexOutOfBoundsException::IndexOutOfBoundsException()
 97                : Exception("index out of bounds")
 98 kumpf 1.54 {
 99            }
100 chuck 1.65 */
101 mike  1.22 
102 chuck 1.64 IndexOutOfBoundsException::IndexOutOfBoundsException()
103 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.IndexOutOfBoundsException","index out of bounds"))
104 chuck 1.64 {
105            }
106            
107 chuck 1.65 /*
108 kumpf 1.55 AlreadyExistsException::AlreadyExistsException(const String& message)
109 kumpf 1.54     : Exception("already exists: " + message)
110            {
111            }
112 chuck 1.65 */
113 mike  1.22 
114 chuck 1.64 AlreadyExistsException::AlreadyExistsException(const String& message)
115 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.AlreadyExistsException",
116                								"already exists: $0",    								
117 chuck 1.64     								 message))
118            {
119            }
120            
121 chuck 1.65 AlreadyExistsException::AlreadyExistsException(MessageLoaderParms& msgParms)
122                : Exception(MessageLoaderParms("Common.Exception.AlreadyExistsException",
123 chuck 1.64     								"already exists: "))
124            {
125 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
126 chuck 1.64 }
127            
128 chuck 1.65 /*
129 kumpf 1.54 InvalidNameException::InvalidNameException(const String& name)
130                : Exception("invalid CIM name: " + name)
131            {
132            }
133 chuck 1.65 */
134 mike  1.22 
135 chuck 1.64 InvalidNameException::InvalidNameException(const String& message)
136 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.InvalidNameException",
137                								"invalid CIM name: $0",
138 chuck 1.64     								 message))
139            {
140            }
141            
142 chuck 1.65 InvalidNameException::InvalidNameException(MessageLoaderParms& msgParms)
143                : Exception(MessageLoaderParms("Common.Exception.InvalidNameException",
144 chuck 1.64     								"invalid CIM name: "))
145            {
146 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
147 chuck 1.64 }
148            
149 chuck 1.65 /*
150 kumpf 1.54 InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
151                : Exception("invalid CIM namespace name: " + name)
152            {
153            }
154 chuck 1.65 */
155            
156 kumpf 1.44 
157 chuck 1.64 InvalidNamespaceNameException::InvalidNamespaceNameException(const String& name)
158 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.InvalidNamespaceNameException",
159                								"invalid CIM namespace name: $0",
160 chuck 1.64     								 name))
161            {
162            }
163            
164 chuck 1.65 InvalidNamespaceNameException::InvalidNamespaceNameException(MessageLoaderParms& msgParms)
165                : Exception(MessageLoaderParms("Common.Exception.InvalidNamespaceNameException",
166 chuck 1.64     								"invalid CIM namespace name: "))
167            {
168 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
169 chuck 1.64 }
170            
171 chuck 1.65 /*
172 kumpf 1.55 UninitializedObjectException::UninitializedObjectException()
173 kumpf 1.54     : Exception("uninitialized object")
174            {
175            }
176 chuck 1.65 */
177 mike  1.22 
178 chuck 1.64 UninitializedObjectException::UninitializedObjectException()
179 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.UninitializedObjectException",
180 chuck 1.64     								"uninitialized object"))
181            {
182            }
183            
184 chuck 1.65 /*
185 kumpf 1.55 TypeMismatchException::TypeMismatchException()
186 kumpf 1.54     : Exception("type mismatch")
187            {
188            }
189 chuck 1.65 */
190 mike  1.22 
191 chuck 1.64 TypeMismatchException::TypeMismatchException()
192 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.TypeMismatchException",
193 chuck 1.64     								"type mismatch"))
194            {
195            }
196            
197 chuck 1.65 /*
198 kumpf 1.55 DynamicCastFailedException::DynamicCastFailedException()
199 kumpf 1.54     : Exception("dynamic cast failed")
200            {
201            }
202 chuck 1.65 */
203 mike  1.24 
204 chuck 1.64 DynamicCastFailedException::DynamicCastFailedException()
205 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.DynamicCastFailedException",
206 chuck 1.64     								"dynamic cast failed"))
207            {
208            }
209            
210 chuck 1.65 /*
211 kumpf 1.55 InvalidDateTimeFormatException::InvalidDateTimeFormatException()
212                : Exception("invalid datetime format")
213 kumpf 1.54 {
214            }
215 chuck 1.65 */
216 mike  1.22 
217 chuck 1.64 InvalidDateTimeFormatException::InvalidDateTimeFormatException()
218 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.InvalidDateTimeFormatException",
219 chuck 1.64     								"invalid datetime format"))
220            {
221            }
222            
223 chuck 1.65 /*
224 kumpf 1.54 MalformedObjectNameException::MalformedObjectNameException(
225                const String& objectName)
226                : Exception("malformed object name: " + objectName)
227            {
228            }
229 chuck 1.65 */
230 mike  1.22 
231 chuck 1.64 MalformedObjectNameException::MalformedObjectNameException(const String& message)
232 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.MalformedObjectNameException",
233                								"malformed object name: $0",
234 chuck 1.64     								 message))
235            {
236            }
237            
238 chuck 1.65 MalformedObjectNameException::MalformedObjectNameException(MessageLoaderParms& msgParms)
239                : Exception(MessageLoaderParms("Common.Exception.MalformedObjectNameException",
240 chuck 1.64     								"malformed object name: "))
241            {
242 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
243 chuck 1.64 }
244            
245 chuck 1.65 /*
246 kumpf 1.54 BindFailedException::BindFailedException(const String& message)
247                : Exception("Bind failed: " + message)
248            {
249            }
250 chuck 1.65 */
251 mike  1.23 
252 chuck 1.64 BindFailedException::BindFailedException(const String& message)
253 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.BindFailedException",
254                								"Bind failed: $0",
255 chuck 1.64     								 message))
256            {
257            }
258            
259 chuck 1.65 BindFailedException::BindFailedException(MessageLoaderParms& msgParms)
260                : Exception(MessageLoaderParms("Common.Exception.BindFailedException",
261 chuck 1.64     								"Bind failed: "))
262            {
263 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
264 chuck 1.64 }
265            
266 chuck 1.65 /*
267 kumpf 1.54 InvalidLocatorException::InvalidLocatorException(const String& locator)
268                : Exception("Invalid locator: " + locator)
269            {
270            }
271 chuck 1.65 */
272 mike  1.23 
273 chuck 1.64 InvalidLocatorException::InvalidLocatorException(const String& message)
274 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.InvalidLocatorException",
275                								"Invalid locator: $0",
276 chuck 1.64     								 message))
277            {
278            }
279            
280 chuck 1.65 InvalidLocatorException::InvalidLocatorException(MessageLoaderParms& msgParms)
281                : Exception(MessageLoaderParms("Common.Exception.InvalidLocatorException",
282 chuck 1.64     								"Invalid locator: "))
283            {
284 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
285 chuck 1.64 }
286            
287 chuck 1.65 /*
288 kumpf 1.54 CannotCreateSocketException::CannotCreateSocketException()
289                : Exception("Cannot create socket")
290            {
291            }
292 chuck 1.65 */
293 mike  1.23 
294 chuck 1.64 CannotCreateSocketException::CannotCreateSocketException()
295 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.CannotCreateSocketException",
296 chuck 1.64     								"Cannot create socket"))
297            {
298            }
299            
300 chuck 1.65 
301            CannotConnectException::CannotConnectException(const String& message)//???
302 kumpf 1.63     : Exception(message)
303 kumpf 1.54 {
304            }
305 chuck 1.65 
306            
307            CannotConnectException::CannotConnectException(MessageLoaderParms& msgParms)
308 chuck 1.64     : Exception(msgParms)
309            {
310            }
311 mike  1.23 
312 chuck 1.65 /*
313 kumpf 1.54 AlreadyConnectedException::AlreadyConnectedException()
314                : Exception("already connected")
315            {
316            }
317 chuck 1.65 */
318 mike  1.23 
319 chuck 1.64 AlreadyConnectedException::AlreadyConnectedException()
320 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.AlreadyConnectedException",
321 chuck 1.64     								"already connected"))
322            {
323            }
324            
325 chuck 1.65 /*
326 kumpf 1.54 NotConnectedException::NotConnectedException()
327                : Exception("not connected")
328            {
329            }
330 chuck 1.65 */
331 mike  1.22 
332 chuck 1.64 NotConnectedException::NotConnectedException()
333 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.NotConnectedException",
334 chuck 1.64     								"not connected"))
335            {
336            }
337            
338 chuck 1.65 /*
339 kumpf 1.54 ConnectionTimeoutException::ConnectionTimeoutException()
340                : Exception("connection timed out")
341            {
342            }
343 chuck 1.65 */
344 kumpf 1.26 
345 chuck 1.64 ConnectionTimeoutException::ConnectionTimeoutException()
346 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.ConnectionTimeoutException",
347 chuck 1.64     								"connection timed out"))
348            {
349            }
350            
351 chuck 1.65 /*
352 kumpf 1.54 SSLException::SSLException(const String& message)
353                : Exception("SSL Exception: " + message)
354            {
355            }
356 chuck 1.65 */
357 kumpf 1.40 
358 chuck 1.64 SSLException::SSLException(const String& message)
359 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.SSLException",
360                								"SSL Exception: $0" ,
361 chuck 1.64     								 message))
362            {
363            }
364            
365 chuck 1.65 SSLException::SSLException(MessageLoaderParms& msgParms)
366                : Exception(MessageLoaderParms("Common.Exception.SSLException",
367 chuck 1.64     								"SSL Exception: " ))
368            {
369 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
370 chuck 1.64 }
371            
372 chuck 1.65 /*
373 kumpf 1.62 DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
374                : Exception("DateTime is out of range : " + message)
375            {
376            }
377 chuck 1.65 */
378 kumpf 1.26 
379 chuck 1.64 DateTimeOutOfRangeException::DateTimeOutOfRangeException(const String& message)
380 chuck 1.65     : Exception(MessageLoaderParms("Common.Exception.DateTimeOutOfRangeException",
381                								"DateTime is out of range : $0" ,
382 chuck 1.64     								 message))
383            {
384            }
385            
386 chuck 1.65 DateTimeOutOfRangeException::DateTimeOutOfRangeException(MessageLoaderParms& msgParms)
387                : Exception(MessageLoaderParms("Common.Exception.DateTimeOutOfRangeException",
388 chuck 1.64     								"DateTime is out of range : " ))
389            {
390 chuck 1.65 	_rep->message.append(MessageLoader::getMessage(msgParms));
391 chuck 1.64 }
392 chuck 1.65 
393 chuck 1.64 
394 mike  1.22 ////////////////////////////////////////////////////////////////////////////////
395            //
396            // CIMException
397            //
398            ////////////////////////////////////////////////////////////////////////////////
399            
400 chuck 1.64 // l10n - note - use this when you have an exception with no
401            // detail message, or one with an untranslated detail message
402            // The pegasus message associated with code will be translated.
403 kumpf 1.53 CIMException::CIMException(
404 kumpf 1.29     CIMStatusCode code,
405 kumpf 1.37     const String& message)
406 kumpf 1.61     : Exception()
407 kumpf 1.29 {
408 kumpf 1.59     CIMExceptionRep * tmp = new CIMExceptionRep ();
409                tmp->message = message;
410                tmp->code = code;
411                tmp->file = "";
412                tmp->line = 0;
413 chuck 1.64     tmp->contentLanguages = ContentLanguages::EMPTY;     
414                tmp->cimMessage = String::EMPTY;    
415                _rep = tmp;
416            }
417            
418            // l10n - note use this when you have an exception with a translated
419            // detail message
420            // l10n
421            CIMException::CIMException(
422                CIMStatusCode code,
423                const MessageLoaderParms& msgParms)
424                : Exception()
425            {
426                CIMExceptionRep * tmp = new CIMExceptionRep ();
427                tmp->message = MessageLoader::getMessage(
428                	const_cast<MessageLoaderParms &>(msgParms));
429                // Must be after MessageLoader::getMessage call
430                tmp->contentLanguages = msgParms.contentlanguages;     
431                tmp->cimMessage = String::EMPTY;
432                tmp->code = code;
433                tmp->file = "";
434 chuck 1.64     tmp->line = 0;
435 kumpf 1.59     _rep = tmp;
436 kumpf 1.29 }
437            
438 kumpf 1.53 CIMException::CIMException(const CIMException & cimException)
439 kumpf 1.61     : Exception()
440 kumpf 1.53 {
441 kumpf 1.59     CIMExceptionRep * tmp = new CIMExceptionRep ();
442                CIMExceptionRep * rep;
443                rep = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
444                tmp->message = rep->message;
445 chuck 1.64     tmp->contentLanguages = rep->contentLanguages;  // l10n
446                tmp->cimMessage = rep->cimMessage;  // l10n    
447 kumpf 1.59     tmp->code = rep->code;
448                tmp->file = rep->file;
449                tmp->line = rep->line;
450                _rep = tmp;
451 mike  1.22 }
452            
453 kumpf 1.53 CIMException& CIMException::operator=(const CIMException & cimException)
454 mike  1.22 {
455 kumpf 1.59     CIMExceptionRep* left;
456                CIMExceptionRep* right;
457                left = reinterpret_cast<CIMExceptionRep*>(this->_rep);
458                right = reinterpret_cast<CIMExceptionRep*>(cimException._rep);
459                left->message = right->message;
460 chuck 1.64     left->contentLanguages = right->contentLanguages;  // l10n    
461                left->cimMessage = right->cimMessage;  // l10n
462 kumpf 1.59     left->code = right->code;
463                left->file = right->file;
464                left->line = right->line;
465 kumpf 1.53     return *this;
466 kumpf 1.32 }
467            
468 kumpf 1.53 CIMException::~CIMException()
469 kumpf 1.37 {
470            }
471            
472 kumpf 1.53 CIMStatusCode CIMException::getCode() const
473 kumpf 1.37 {
474 kumpf 1.59     CIMExceptionRep* rep;
475                rep = reinterpret_cast<CIMExceptionRep*>(_rep);
476                return rep->code;
477 mike  1.22 }
478            
479            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2