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

  1 kumpf 1.1 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3           // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4           // The Open Group, Tivoli Systems
  5           //
  6           // Permission is hereby granted, free of charge, to any person obtaining a copy
  7           // 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           // 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           // 
 13           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14           // 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           // 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           // 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 kumpf 1.1 //==============================================================================
 23           //
 24           // Author: Mike Brasher (mbrasher@bmc.com)
 25           //
 26           // Modified By: Nag Boranna (nagaraja_boranna@hp.com)
 27           //
 28           // Modified By: Jenny Yu (jenny_yu@am.exch.hp.com)
 29           //              Carol Ann Krug Graves, Hewlett-Packard Company
 30           //                (carolann_graves@hp.com)
 31 mday  1.6.14.1 // 
 32 kumpf 1.1      //%/////////////////////////////////////////////////////////////////////////////
 33                
 34                #include <cstdio>
 35                #include "InternalException.h"
 36 kumpf 1.2      #include <Pegasus/Common/CIMExceptionRep.h>
 37 mday  1.6.14.1 #include <Pegasus/Common/ContentLanguages.h>  // l10n
 38 kumpf 1.1      #include "Tracer.h"
 39                
 40                PEGASUS_NAMESPACE_BEGIN
 41                
 42                AssertionFailureException::AssertionFailureException(
 43                    const char* file,
 44                    size_t line,
 45 kumpf 1.2          const String& message) : Exception(String::EMPTY)
 46 kumpf 1.1      {
 47                    char lineStr[32];
 48 kumpf 1.6          sprintf(lineStr, "%u", Uint32(line));
 49 kumpf 1.1      
 50 kumpf 1.5          _rep->message = file;
 51                    _rep->message.append("(");
 52                    _rep->message.append(lineStr);
 53                    _rep->message.append("): ");
 54                    _rep->message.append(message);
 55 kumpf 1.1      
 56                    // ATTN-RK-P3-20020408: Should define a "test" trace component
 57 kumpf 1.5          PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2, _rep->message);
 58 kumpf 1.1      }
 59                
 60                const char NullPointer::MSG[] = "null pointer";
 61                
 62                const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";
 63                
 64                const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";
 65                
 66                const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";
 67                
 68                const char BadQualifierType::MSG[] =
 69                    "CIMType of qualifier different than its declaration: ";
 70                
 71                const char ClassAlreadyResolved::MSG[] =
 72                    "attempt to resolve a class that is already resolved: ";
 73                
 74                const char ClassNotResolved::MSG[] =
 75                    "class is not yet resolved: ";
 76                
 77                const char InstanceAlreadyResolved::MSG[] =
 78                    "attempted to resolve a instance that is already resolved";
 79 kumpf 1.1      
 80                const char InstantiatedAbstractClass::MSG[] =
 81                    "attempted to instantiate an abstract class ";
 82                
 83                const char NoSuchProperty::MSG[] = "no such property: ";
 84                
 85                const char NoSuchFile::MSG[] = "no such file: ";
 86                
 87                const char FileNotReadable::MSG[] = "file not readable: ";
 88                
 89                const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";
 90                
 91                const char CannotRemoveFile::MSG[] = "cannot remove file: ";
 92                
 93                const char CannotRenameFile::MSG[] = "cannot rename file: ";
 94                
 95                const char NoSuchDirectory::MSG[] = "no such directory: ";
 96                
 97                const char CannotCreateDirectory::MSG[] = "cannot create directory: ";
 98                
 99                const char CannotOpenFile::MSG[] = "cannot open file: ";
100 kumpf 1.1      
101                const char NotImplemented::MSG[] = "not implemented: ";
102                
103                const char StackUnderflow::MSG[] = "stack underflow";
104                
105                const char StackOverflow::MSG[] = "stack overflow";
106                
107                const char QueueUnderflow::MSG[] = "queue Underflow";
108                
109                const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
110                
111                const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
112                
113                const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";
114                
115                const char DynamicLookupFailed::MSG[] =
116                    "lookup of symbol in dynamic library failed: ";
117                
118                const char CannotOpenDirectory::MSG[] = "cannot open directory: ";
119                
120                const char ParseError::MSG[] = "parse error: ";
121 kumpf 1.1      
122                const char MissingNullTerminator::MSG[] = "missing null terminator: ";
123                
124 mday  1.6.14.1 //l10n
125                const char MalformedLanguageHeader::MSG[] = "malformed language header: ";
126                
127                const char InvalidAcceptLanguageHeader::MSG[] = "invalid acceptlanguage header: ";
128                
129                const char InvalidContentLanguageHeader::MSG[] = "invalid contentlanguage header: ";
130                //l10n
131                
132 kumpf 1.1      const char InvalidAuthHeader::MSG[] = "Invalid Authorization header";
133                
134                const char UnauthorizedAccess::MSG[] = "Unauthorized access";
135                
136 kumpf 1.4      IncompatibleTypesException::IncompatibleTypesException()
137                    : Exception("incompatible types")
138                {
139                }
140                
141 kumpf 1.1      
142                ////////////////////////////////////////////////////////////////////////////////
143                //
144 kumpf 1.2      // TraceableCIMException
145 kumpf 1.1      //
146                ////////////////////////////////////////////////////////////////////////////////
147                
148                //
149                // Creates a description without source file name and line number.
150                //
151                static String _makeCIMExceptionDescription(
152                    CIMStatusCode code,
153                    const String& message)
154                {
155                    String tmp;
156                    tmp.append(cimStatusCodeToString(code));
157                    if (message != String::EMPTY)
158                    {
159                        tmp.append(": \"");
160                        tmp.append(message);
161                        tmp.append("\"");
162                    }
163                    return tmp;
164                }
165                
166 mday  1.6.14.1 // l10n
167                //
168                // Creates a description without source file name and line number.
169                //
170                static String _makeCIMExceptionDescription(
171                    CIMStatusCode code,
172                    const String& message,
173                    ContentLanguages &contentLanguages)
174                {
175                    String tmp;
176                    tmp = cimStatusCodeToString(code, contentLanguages);
177                    if (message != String::EMPTY)
178                    {
179                        tmp.append(": \"");
180                        tmp.append(message);
181                        tmp.append("\"");
182                    }
183                    return tmp;
184                }
185                
186                // l10n
187 mday  1.6.14.1 //
188                // Creates a description without source file name and line number.
189                //
190                static String _makeCIMExceptionDescription(
191                    const String& cimMessage,
192                    const String& extraMessage)
193                {
194                    String tmp;
195                    tmp = cimMessage;
196                    if (extraMessage != String::EMPTY)
197                    {
198                        tmp.append(": \"");
199                        tmp.append(extraMessage);
200                        tmp.append("\"");
201                    }
202                    return tmp;
203                }
204                
205 kumpf 1.1      //
206                // Creates a description with source file name and line number.
207                //
208                static String _makeCIMExceptionDescription(
209                    CIMStatusCode code,
210                    const String& message,
211                    const char* file,
212                    Uint32 line)
213                {
214                    String tmp = file;
215                    tmp.append("(");
216                    char buffer[32];
217                    sprintf(buffer, "%d", line);
218                    tmp.append(buffer);
219                    tmp.append("): ");
220                    tmp.append(_makeCIMExceptionDescription(code, message));
221                    return tmp;
222                }
223                
224 kumpf 1.2      TraceableCIMException::TraceableCIMException(
225 kumpf 1.1          CIMStatusCode code,
226                    const String& message,
227                    const char* file,
228                    Uint32 line)
229                    :
230 kumpf 1.2          CIMException(code, message)
231 kumpf 1.1      {
232 kumpf 1.5          CIMExceptionRep* rep;
233                    rep = reinterpret_cast<CIMExceptionRep*>(_rep);
234                    rep->file = file;
235                    rep->line = line;
236 mday  1.6.14.1 
237                // l10n
238                	// Localize the cim message from the code.  Use the language of
239                	// the current thread.
240                	rep->contentLanguages = cimStatusCodeToString_Thread(rep->cimMessage, code);
241                }
242                
243                // l10n
244                TraceableCIMException::TraceableCIMException(
245                	const ContentLanguages& langs,
246                    CIMStatusCode code,
247                    const String& message,
248                    const char* file,
249                    Uint32 line)
250                    :
251                    CIMException(code, message)
252                {
253                    CIMExceptionRep* rep;
254                    rep = reinterpret_cast<CIMExceptionRep*>(_rep);
255                    rep->file = file;
256                    rep->line = line;
257 mday  1.6.14.1 
258                // l10n
259                	rep->contentLanguages = langs;
260 kumpf 1.2      }
261 kumpf 1.1      
262 kumpf 1.2      TraceableCIMException::TraceableCIMException(const CIMException & cimException)
263                    : CIMException(cimException.getCode(), cimException.getMessage())
264                {
265                    TraceableCIMException * t = (TraceableCIMException *)&cimException;
266 kumpf 1.5          CIMExceptionRep* left;
267                    CIMExceptionRep* right;
268                    left = reinterpret_cast<CIMExceptionRep*>(_rep);
269                    right = reinterpret_cast<CIMExceptionRep*>(t->_rep);
270                    left->file = right->file;
271                    left->line = right->line;
272 mday  1.6.14.1 // l10n    
273                    left->contentLanguages = right->contentLanguages;    
274                    left->cimMessage = right->cimMessage;
275 kumpf 1.1      }
276                
277                //
278                // Returns a description string fit for human consumption
279                //
280 kumpf 1.2      String TraceableCIMException::getDescription() const
281 kumpf 1.1      {
282 kumpf 1.2      #ifdef PEGASUS_DEBUG_CIMEXCEPTION
283 kumpf 1.1          return getTraceDescription();
284                #else
285 kumpf 1.5          CIMExceptionRep* rep;
286                    rep = reinterpret_cast<CIMExceptionRep*>(_rep);
287 mday  1.6.14.1 // l10n  - TODO uncomment when CIMStatus code is done
288                	return _makeCIMExceptionDescription(rep->code, getMessage());  
289                /*	
290                	if (rep->cimMessage == String::EMPTY)
291                	{
292                	    return _makeCIMExceptionDescription(rep->code, 
293                    										getMessage(),
294                    										rep->contentLanguages);    		
295                	}
296                	else
297                	{
298                		return _makeCIMExceptionDescription(rep->cimMessage,
299                											getMessage());
300                	}
301                */
302 kumpf 1.1      #endif
303                }
304                
305                //
306                // Returns a description string with filename and line number information
307                // specifically for tracing.
308                //
309 kumpf 1.2      String TraceableCIMException::getTraceDescription() const
310 kumpf 1.1      {
311 kumpf 1.5          CIMExceptionRep* rep;
312                    rep = reinterpret_cast<CIMExceptionRep*>(_rep);
313 kumpf 1.1          String traceDescription =
314 kumpf 1.2              _makeCIMExceptionDescription(
315 kumpf 1.5                  rep->code, getMessage(), rep->file, rep->line);
316 kumpf 1.1      
317                    return traceDescription;
318                }
319                
320                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2