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

  1 karl  1.19 //%2006////////////////////////////////////////////////////////////////////////
  2 kumpf 1.1  //
  3 karl  1.16 // 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.13 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.16 // 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.17 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.19 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 kumpf 1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15            // 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            // 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            // 
 21            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 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            // 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            // 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            // Author: Mike Brasher (mbrasher@bmc.com)
 33            //
 34 kumpf 1.1  // Modified By: Nag Boranna (nagaraja_boranna@hp.com)
 35            //
 36            // Modified By: Jenny Yu (jenny_yu@am.exch.hp.com)
 37            //              Carol Ann Krug Graves, Hewlett-Packard Company
 38            //                (carolann_graves@hp.com)
 39 chuck 1.7  // 
 40 kumpf 1.1  //%/////////////////////////////////////////////////////////////////////////////
 41            
 42            #include <cstdio>
 43            #include "InternalException.h"
 44 kumpf 1.2  #include <Pegasus/Common/CIMExceptionRep.h>
 45 kumpf 1.18 #include <Pegasus/Common/ContentLanguageList.h>
 46 kumpf 1.1  #include "Tracer.h"
 47            
 48            PEGASUS_NAMESPACE_BEGIN
 49            
 50            AssertionFailureException::AssertionFailureException(
 51                const char* file,
 52                size_t line,
 53 kumpf 1.2      const String& message) : Exception(String::EMPTY)
 54 kumpf 1.1  {
 55                char lineStr[32];
 56 kumpf 1.6      sprintf(lineStr, "%u", Uint32(line));
 57 kumpf 1.1  
 58 kumpf 1.5      _rep->message = file;
 59                _rep->message.append("(");
 60                _rep->message.append(lineStr);
 61                _rep->message.append("): ");
 62                _rep->message.append(message);
 63 kumpf 1.1  
 64 kumpf 1.15     PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, _rep->message);
 65 kumpf 1.1  }
 66            
 67            const char NullPointer::MSG[] = "null pointer";
 68 humberto 1.11 const char NullPointer::KEY[] = "Common.InternalException.NULL_POINTER";
 69 kumpf    1.1  
 70 humberto 1.12 //l10n 
 71 humberto 1.9  const char UndeclaredQualifier::MSG[] = "undeclared qualifier: $0";
 72 humberto 1.11 const char UndeclaredQualifier::KEY[] = "Common.InternalException.UNDECLARED_QUALIFIER";
 73 kumpf    1.1  
 74 humberto 1.12 //l10n 
 75               const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: $0 scope=$1";
 76 humberto 1.11 const char BadQualifierScope::KEY[] = "Common.InternalException.BAD_QUALIFIER_SCOPE";
 77 kumpf    1.1  
 78 humberto 1.12 //l10n 
 79               const char BadQualifierOverride::MSG[] = "qualifier not overridable: $0";
 80 humberto 1.11 const char BadQualifierOverride::KEY[] = "Common.InternalException.BAD_QUALIFIER_OVERRIDE"; 
 81 kumpf    1.1  
 82 humberto 1.12 //l10n 
 83               const char BadQualifierType::MSG[] = "CIMType of qualifier different than its declaration: $0";
 84 humberto 1.11 const char BadQualifierType::KEY[] = "Common.InternalException.BAD_QUALIFIER_TYPE";
 85 kumpf    1.1  
 86 humberto 1.12 const char ClassAlreadyResolved::MSG[] = "attempt to resolve a class that is already resolved: $0";
 87 humberto 1.11 const char ClassAlreadyResolved::KEY[] = "Common.InternalException.CLASS_ALREADY_RESOLVED";
 88 kumpf    1.1  
 89 humberto 1.12 //l10n 
 90               const char ClassNotResolved::MSG[] = "class is not yet resolved: $0";
 91 humberto 1.11 const char ClassNotResolved::KEY[] = "Common.InternalException.CLASS_NOT_RESOLVED";
 92 kumpf    1.1  
 93 chuck    1.8  const char InstanceAlreadyResolved::MSG[] = "attempted to resolve a instance that is already resolved";
 94 humberto 1.11 const char InstanceAlreadyResolved::KEY[] = "Common.InternalException.INSTANCE_ALREADY_RESOLVED"; 
 95 kumpf    1.1  
 96 humberto 1.12 //l10n 
 97               const char InstantiatedAbstractClass::MSG[] = "attempted to instantiate an abstract class $0";
 98 humberto 1.11 const char InstantiatedAbstractClass::KEY[] = "Common.InternalException.INSTANTIATED_ABSTRACT_CLASS"; 
 99 kumpf    1.1  
100 humberto 1.12 //l10n 
101               const char NoSuchProperty::MSG[] = "no such property: $0";
102 humberto 1.11 const char NoSuchProperty::KEY[] = "Common.InternalException.NO_SUCH_PROPERTY";
103 kumpf    1.1  
104 humberto 1.12 //l10n 
105               const char NoSuchFile::MSG[] = "no such file: $0";
106 humberto 1.11 const char NoSuchFile::KEY[] = "Common.InternalException.NO_SUCH_FILE";
107 kumpf    1.1  
108 humberto 1.12 //l10n 
109               const char FileNotReadable::MSG[] = "file not readable: $0";
110 humberto 1.11 const char FileNotReadable::KEY[] = "Common.InternalException.FILE_NOT_READABLE";
111 kumpf    1.1  
112 humberto 1.12 //l10n 
113               const char CannotRemoveDirectory::MSG[] = "cannot remove directory: $0";
114 humberto 1.11 const char CannotRemoveDirectory::KEY[] = "Common.InternalException.CANNOT_REMOVE_DIRECTORY";  
115 kumpf    1.1  
116 humberto 1.12 //l10n 
117               const char CannotRemoveFile::MSG[] = "cannot remove file: $0";
118 humberto 1.11 const char CannotRemoveFile::KEY[] = "Common.InternalException.CANNOT_REMOVE_FILE"; 
119 kumpf    1.1  
120 humberto 1.12 //l10n 
121               const char CannotRenameFile::MSG[] = "cannot rename file: $0";
122 humberto 1.11 const char CannotRenameFile::KEY[] = "Common.InternalException.CANNOT_RENAME_FILE";
123 kumpf    1.1  
124 humberto 1.12 //l10n 
125               const char NoSuchDirectory::MSG[] = "no such directory: $0";
126 humberto 1.11 const char NoSuchDirectory::KEY[] = "Common.InternalException.NO_SUCH_DIRECTORY";  
127 kumpf    1.1  
128 humberto 1.12 //l10n 
129               const char CannotCreateDirectory::MSG[] = "cannot create directory: $0";
130 humberto 1.11 const char CannotCreateDirectory::KEY[] = "Common.InternalException.CANNOT_CREATE_DIRECTORY";
131 kumpf    1.1  
132 humberto 1.12 //l10n 
133               const char CannotOpenFile::MSG[] = "cannot open file: $0";
134 humberto 1.11 const char CannotOpenFile::KEY[] = "Common.InternalException.CANNOT_OPEN_FILE";
135 kumpf    1.1  
136 humberto 1.12 //l10n 
137               const char NotImplemented::MSG[] = "not implemented: $0";
138 humberto 1.11 const char NotImplemented::KEY[] = "Common.InternalException.NOT_IMPLEMENTED"; 
139 kumpf    1.1  
140               const char StackUnderflow::MSG[] = "stack underflow";
141 humberto 1.11 const char StackUnderflow::KEY[] = "Common.InternalException.STACK_UNDERFLOW";
142 kumpf    1.1  
143               const char StackOverflow::MSG[] = "stack overflow";
144 humberto 1.11 const char StackOverflow::KEY[] = "Common.InternalException.STACK_OVERFLOW"; 
145 kumpf    1.1  
146               const char QueueUnderflow::MSG[] = "queue Underflow";
147 humberto 1.11 const char QueueUnderflow::KEY[] = "Common.InternalException.QUEUE UNDERFLOW"; 
148 kumpf    1.1  
149               const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
150 humberto 1.11 const char BadFormat::KEY[] = "Common.InternalException.BAD_FORMAT";
151 kumpf    1.1  
152               const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
153 humberto 1.11 const char BadlyFormedCGIQueryString::KEY[] = "Common.InternalException.BADLY_FORMED_CGI_QUERY_STRING"; 
154 kumpf    1.1  
155 humberto 1.12 //l10n 
156               const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: $0";
157 humberto 1.11 const char DynamicLoadFailed::KEY[] = "Common.InternalException.DYNAMIC_LOAD_FAILED";
158 kumpf    1.1  
159 humberto 1.12 //l10n 
160               const char DynamicLookupFailed::MSG[] = "lookup of symbol in dynamic library failed: $0";
161 humberto 1.11 const char DynamicLookupFailed::KEY[] = "Common.InternalException.DYNAMIC_LOOKUP_FAILED";
162 kumpf    1.1  
163 humberto 1.12 //l10n 
164               const char CannotOpenDirectory::MSG[] = "cannot open directory: $0";
165 humberto 1.11 const char CannotOpenDirectory::KEY[] = "Common.InternalException.CANNOT_OPEN_DIRECTORY"; 
166 kumpf    1.1  
167 humberto 1.12 //l10n 
168               const char ParseError::MSG[] = "parse error: $0";
169 humberto 1.11 const char ParseError::KEY[] = "Common.InternalException.PARSE_ERROR";
170 kumpf    1.1  
171 humberto 1.12 //l10n 
172               const char MissingNullTerminator::MSG[] = "missing null terminator: $0";
173 humberto 1.11 const char MissingNullTerminator::KEY[] = "Common.InternalException.MISSING_NULL_TERMINATOR";
174 kumpf    1.1  
175 chuck    1.7  //l10n
176 humberto 1.12 const char MalformedLanguageHeader::MSG[] = "malformed language header: $0";
177 humberto 1.11 const char MalformedLanguageHeader::KEY[] = "Common.InternalException.MALFORMED_LANGUAGE_HEADER";
178 chuck    1.7  
179 humberto 1.12 //l10n 
180               const char InvalidAcceptLanguageHeader::MSG[] = "invalid acceptlanguage header: $0";
181 humberto 1.11 const char InvalidAcceptLanguageHeader::KEY[] = "Common.InternalException.INVALID_ACCEPTLANGUAGE_HEADER";
182 chuck    1.7  
183 humberto 1.12 //l10n 
184               const char InvalidContentLanguageHeader::MSG[] = "invalid contentlanguage header: $0";
185 humberto 1.11 const char InvalidContentLanguageHeader::KEY[] = "Common.InternalException.INVALID_CONTENTLANGUAGE_HEADER";
186 chuck    1.7  
187 kumpf    1.1  const char InvalidAuthHeader::MSG[] = "Invalid Authorization header";
188 humberto 1.11 const char InvalidAuthHeader::KEY[] = "Common.InternalException.INVALID_AUTH_HEADER"; 
189 kumpf    1.1  
190               const char UnauthorizedAccess::MSG[] = "Unauthorized access";
191 humberto 1.11 const char UnauthorizedAccess::KEY[] = "Common.InternalException.UNAUTHORIZED_ACCESS";  
192 kumpf    1.1  
193 kumpf    1.14 const char InternalSystemError::MSG[] = "Unable to authenticate user";
194               
195 kumpf    1.4  IncompatibleTypesException::IncompatibleTypesException()
196                   : Exception("incompatible types")
197               {
198               }
199               
200 kumpf    1.1  
201               ////////////////////////////////////////////////////////////////////////////////
202               //
203 kumpf    1.2  // TraceableCIMException
204 kumpf    1.1  //
205               ////////////////////////////////////////////////////////////////////////////////
206               
207               //
208               // Creates a description without source file name and line number.
209               //
210               static String _makeCIMExceptionDescription(
211                   CIMStatusCode code,
212                   const String& message)
213               {
214                   String tmp;
215                   tmp.append(cimStatusCodeToString(code));
216                   if (message != String::EMPTY)
217                   {
218                       tmp.append(": \"");
219                       tmp.append(message);
220                       tmp.append("\"");
221                   }
222                   return tmp;
223               }
224               
225 chuck    1.7  // l10n
226               //
227               // Creates a description without source file name and line number.
228               //
229               static String _makeCIMExceptionDescription(
230                   CIMStatusCode code,
231                   const String& message,
232 kumpf    1.18     ContentLanguageList& contentLanguages)
233 chuck    1.7  {
234                   String tmp;
235                   tmp = cimStatusCodeToString(code, contentLanguages);
236                   if (message != String::EMPTY)
237                   {
238                       tmp.append(": \"");
239                       tmp.append(message);
240                       tmp.append("\"");
241                   }
242                   return tmp;
243               }
244               
245               // l10n
246               //
247               // Creates a description without source file name and line number.
248               //
249               static String _makeCIMExceptionDescription(
250                   const String& cimMessage,
251                   const String& extraMessage)
252               {
253                   String tmp;
254 chuck    1.7      tmp = cimMessage;
255                   if (extraMessage != String::EMPTY)
256                   {
257                       tmp.append(": \"");
258                       tmp.append(extraMessage);
259                       tmp.append("\"");
260                   }
261                   return tmp;
262               }
263               
264 kumpf    1.1  //
265               // Creates a description with source file name and line number.
266               //
267               static String _makeCIMExceptionDescription(
268                   CIMStatusCode code,
269                   const String& message,
270 kumpf    1.15     const String& file,
271 kumpf    1.1      Uint32 line)
272               {
273                   String tmp = file;
274                   tmp.append("(");
275                   char buffer[32];
276                   sprintf(buffer, "%d", line);
277                   tmp.append(buffer);
278                   tmp.append("): ");
279                   tmp.append(_makeCIMExceptionDescription(code, message));
280                   return tmp;
281               }
282               
283 humberto 1.10 //l10n 
284               TraceableCIMException::TraceableCIMException(
285                   CIMStatusCode code,
286                   MessageLoaderParms parms,
287 kumpf    1.15     const String& file,
288 humberto 1.10     Uint32 line)
289                   :
290                   CIMException(code, parms)
291               {
292                   CIMExceptionRep* rep;
293                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
294                   rep->file = file;
295                   rep->line = line;
296               
297               // l10n
298               	// Localize the cim message from the code.  Use the language of
299               	// the current thread.
300               	rep->contentLanguages = cimStatusCodeToString_Thread(rep->cimMessage, code);
301               }
302               
303 kumpf    1.2  TraceableCIMException::TraceableCIMException(
304 kumpf    1.1      CIMStatusCode code,
305                   const String& message,
306 kumpf    1.15     const String& file,
307 kumpf    1.1      Uint32 line)
308                   :
309 kumpf    1.2      CIMException(code, message)
310 kumpf    1.1  {
311 kumpf    1.5      CIMExceptionRep* rep;
312                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
313                   rep->file = file;
314                   rep->line = line;
315 chuck    1.7  
316               // l10n
317               	// Localize the cim message from the code.  Use the language of
318               	// the current thread.
319               	rep->contentLanguages = cimStatusCodeToString_Thread(rep->cimMessage, code);
320               }
321               
322               // l10n
323               TraceableCIMException::TraceableCIMException(
324 kumpf    1.18 	const ContentLanguageList& langs,
325 chuck    1.7      CIMStatusCode code,
326                   const String& message,
327 kumpf    1.15     const String& file,
328 chuck    1.7      Uint32 line)
329                   :
330                   CIMException(code, message)
331               {
332                   CIMExceptionRep* rep;
333                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
334                   rep->file = file;
335                   rep->line = line;
336               
337               // l10n
338               	rep->contentLanguages = langs;
339 kumpf    1.2  }
340 kumpf    1.1  
341 kumpf    1.2  TraceableCIMException::TraceableCIMException(const CIMException & cimException)
342                   : CIMException(cimException.getCode(), cimException.getMessage())
343               {
344                   TraceableCIMException * t = (TraceableCIMException *)&cimException;
345 kumpf    1.5      CIMExceptionRep* left;
346                   CIMExceptionRep* right;
347                   left = reinterpret_cast<CIMExceptionRep*>(_rep);
348                   right = reinterpret_cast<CIMExceptionRep*>(t->_rep);
349                   left->file = right->file;
350                   left->line = right->line;
351 chuck    1.7  // l10n    
352                   left->contentLanguages = right->contentLanguages;    
353                   left->cimMessage = right->cimMessage;
354 kumpf    1.1  }
355               
356               //
357               // Returns a description string fit for human consumption
358               //
359 kumpf    1.2  String TraceableCIMException::getDescription() const
360 kumpf    1.1  {
361 kumpf    1.2  #ifdef PEGASUS_DEBUG_CIMEXCEPTION
362 kumpf    1.1      return getTraceDescription();
363               #else
364 kumpf    1.5      CIMExceptionRep* rep;
365                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
366 chuck    1.8  	
367 chuck    1.7  	if (rep->cimMessage == String::EMPTY)
368               	{
369               	    return _makeCIMExceptionDescription(rep->code, 
370                   										getMessage(),
371                   										rep->contentLanguages);    		
372               	}
373               	else
374               	{
375               		return _makeCIMExceptionDescription(rep->cimMessage,
376               											getMessage());
377               	}
378 chuck    1.8  
379 kumpf    1.1  #endif
380               }
381               
382               //
383               // Returns a description string with filename and line number information
384               // specifically for tracing.
385               //
386 kumpf    1.2  String TraceableCIMException::getTraceDescription() const
387 kumpf    1.1  {
388 kumpf    1.5      CIMExceptionRep* rep;
389                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
390 kumpf    1.1      String traceDescription =
391 kumpf    1.2          _makeCIMExceptionDescription(
392 kumpf    1.5              rep->code, getMessage(), rep->file, rep->line);
393 kumpf    1.1  
394                   return traceDescription;
395               }
396               
397 kumpf    1.15 String TraceableCIMException::getCIMMessage() const
398               {
399                   CIMExceptionRep* rep;
400                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
401                   return rep->cimMessage;
402               }
403               
404               void TraceableCIMException::setCIMMessage(const String& cimMessage)
405               {
406                   CIMExceptionRep* rep;
407                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
408                   rep->cimMessage = cimMessage;
409               }
410               
411               String TraceableCIMException::getFile() const
412               {
413                   CIMExceptionRep* rep;
414                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
415                   return rep->file;
416               }
417               
418 kumpf    1.15 Uint32 TraceableCIMException::getLine() const
419               {
420                   CIMExceptionRep* rep;
421                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
422                   return rep->line;
423               }
424               
425 kumpf    1.18 const ContentLanguageList& TraceableCIMException::getContentLanguages() const
426 kumpf    1.15 {
427                   CIMExceptionRep* rep;
428                   rep = reinterpret_cast<CIMExceptionRep*>(_rep);
429                   return rep->contentLanguages;
430               }
431               
432 kumpf    1.1  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2