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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2