(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 kumpf 1.42 // 
 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 mike  1.23 // Modified By: Nag Boranna (nagaraja_boranna@hp.com)
 27            //
 28 kumpf 1.29 // Modified By: Jenny Yu (jenny_yu@am.exch.hp.com)
 29 mike  1.22 //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32            #include <cstdio>
 33            #include "Exception.h"
 34 kumpf 1.33 #include "Tracer.h"
 35 mike  1.22 
 36            PEGASUS_NAMESPACE_BEGIN
 37            
 38 chip  1.39 Exception::Exception(const String& message) : _message(message)
 39            {
 40 mike  1.22 
 41            }
 42            
 43 chip  1.39 Exception::Exception(const char* message) : _message(message)
 44 mike  1.22 {
 45            
 46            }
 47            
 48            Exception::~Exception()
 49            {
 50            
 51            }
 52            
 53            AssertionFailureException::AssertionFailureException(
 54 chip  1.39     const char* file,
 55 mike  1.22     size_t line,
 56                const String& message) : Exception(String())
 57            {
 58                char lineStr[32];
 59 kumpf 1.30     sprintf(lineStr, "%u", line);
 60 mike  1.22 
 61                _message = file;
 62                _message.append("(");
 63                _message.append(lineStr);
 64                _message.append("): ");
 65                _message.append(message);
 66 kumpf 1.33 
 67                // ATTN-RK-P3-20020408: Should define a "test" trace component
 68                PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2, _message);
 69 mike  1.22 }
 70            
 71            const char OutOfBounds::MSG[] = "out of bounds";
 72            
 73            const char AlreadyExists::MSG[] = "already exists: ";
 74            
 75            const char NullPointer::MSG[] = "null pointer";
 76            
 77 kumpf 1.38 const char UninitializedHandle::MSG[] = "uninitialized handle";
 78 mike  1.22 
 79            const char IllegalName::MSG[] = "illegal CIM name";
 80            
 81            const char InvalidPropertyOverride::MSG[] = "invalid property override: ";
 82            
 83            const char InvalidMethodOverride::MSG[] = "invalid method override: ";
 84            
 85            const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";
 86            
 87            const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";
 88            
 89            const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";
 90            
 91 chip  1.39 const char BadQualifierType::MSG[] =
 92 mike  1.22     "CIMType of qualifier different than its declaration: ";
 93            
 94            const char NullType::MSG[] = "type is null";
 95            
 96 chip  1.39 const char AddedReferenceToClass::MSG[] =
 97 mike  1.22     "attempted to add reference to a non-association class: ";
 98            
 99 chip  1.39 const char ClassAlreadyResolved::MSG[] =
100 mike  1.22     "attempt to resolve a class that is already resolved: ";
101            
102 chip  1.39 const char ClassNotResolved::MSG[] =
103 mike  1.22     "class is not yet resolved: ";
104            
105 chip  1.39 const char InstanceAlreadyResolved::MSG[] =
106 mike  1.22     "attempted to resolve a instance that is already resolved";
107            
108 chip  1.39 const char InstantiatedAbstractClass::MSG[] =
109 karl  1.28     "attempted to instantiate an abstract class ";
110 mike  1.22 
111            const char NoSuchProperty::MSG[] = "no such property: ";
112            
113 chip  1.39 const char TruncatedCharacter::MSG[] =
114 mike  1.22     "truncated character during conversion from Char16 to char";
115            
116 chip  1.39 const char ExpectedReferenceValue::MSG[] =
117 mike  1.22     "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "
118                "in this context";
119            
120            const char MissingReferenceClassName::MSG[] = "missing reference class name";
121            
122            const char IllegalTypeTag::MSG[] = "illegal type tag";
123            
124            const char TypeMismatch::MSG[] = "type mismatch";
125            
126 karl  1.25 const char CIMValueIsNull::MSG[] = "null CIMValue accessed";
127            
128            const char CIMValueInvalidType::MSG[] = "invalid CIMValue type";
129            
130 mike  1.24 const char DynamicCastFailed::MSG[] = "dynamic cast failed";
131            
132 mike  1.22 const char NoSuchFile::MSG[] = "no such file: ";
133            
134 mike  1.23 const char FileNotReadable::MSG[] = "file not readable: ";
135            
136 mike  1.22 const char CannotBindToAddress::MSG[] = "cannot bind to address: ";
137            
138            const char NoSuchDirectory::MSG[] = "no such directory: ";
139            
140            const char ChangeDirectoryFailed::MSG[] = "cannot change directory: ";
141            
142            const char CannotCreateDirectory::MSG[] = "cannot create directory: ";
143            
144            const char NoSuchNameSpace::MSG[] = "no such namespace: ";
145            
146            const char CannotOpenFile::MSG[] = "cannot open file: ";
147            
148            const char NotImplemented::MSG[] = "not implemented: ";
149            
150            const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";
151            
152            const char CannotRemoveFile::MSG[] = "cannot remove file: ";
153            
154            const char CannotRenameFile::MSG[] = "cannot rename file: ";
155            
156 mike  1.23 const char StackUnderflow::MSG[] = "stack underflow";
157            
158            const char StackOverflow::MSG[] = "stack overflow";
159 mike  1.22 
160            const char QueueUnderflow::MSG[] = "queue Underflow";
161            
162            const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
163            
164            const char BadDateTimeFormat::MSG[] = "bad datetime format";
165            
166            const char IncompatibleTypes::MSG[] = "incompatible types";
167            
168            const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
169            
170            const char IllformedObjectName::MSG[] = "illformed object name: ";
171            
172            const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";
173            
174 chip  1.39 const char DynamicLookupFailed::MSG[] =
175 mike  1.22     "lookup of symbol in dynamic library failed: ";
176            
177            const char CannotOpenDirectory::MSG[] = "cannot open directory: ";
178            
179            const char CorruptFile::MSG[] = "corrupt file: ";
180 mike  1.23 
181            const char BindFailed::MSG[] = "Bind failed: ";
182            
183            const char InvalidLocator::MSG[] = "Invalid locator: ";
184            
185            const char CannotCreateSocket::MSG[] = "Cannot create socket";
186            
187            const char CannotConnect::MSG[] = "Cannot connect to: ";
188            
189            const char UnexpectedFailure::MSG[] = "Unexpected failure";
190            
191            const char AlreadyConnected::MSG[] = "already connected";
192            
193            const char NotConnected::MSG[] = "not connected";
194            
195            const char TimedOut::MSG[] = "timed out";
196            
197            const char ParseError::MSG[] = "parse error: ";
198            
199            const char MissingNullTerminator::MSG[] = "missing null terminator: ";
200            
201 mike  1.23 const char SSL_Exception::MSG[] = "SSL Exception ";
202 mike  1.22 
203 kumpf 1.26 const char InvalidAuthHeader::MSG[] = "Invalid Authorization header";
204            
205 kumpf 1.40 const char UnauthorizedAccess::MSG[] = "Unauthorized access";
206            
207 kumpf 1.26 
208 mike  1.22 ////////////////////////////////////////////////////////////////////////////////
209            //
210            // CIMException
211            //
212            ////////////////////////////////////////////////////////////////////////////////
213            
214 kumpf 1.29 //
215 kumpf 1.37 // Creates a description without source file name and line number.
216 kumpf 1.29 //
217 kumpf 1.37 static String _makeCIMExceptionDescription(
218 kumpf 1.29     CIMStatusCode code,
219 kumpf 1.37     const String& message)
220 kumpf 1.29 {
221                String tmp;
222                tmp.append(CIMStatusCodeToString(code));
223 kumpf 1.41     if (message != String::EMPTY)
224                {
225                    tmp.append(": \"");
226                    tmp.append(message);
227                    tmp.append("\"");
228                }
229 kumpf 1.29     return tmp;
230            }
231            
232            //
233 kumpf 1.37 // Creates a description with source file name and line number.
234 kumpf 1.29 //
235 kumpf 1.37 static String _makeCIMExceptionDescription(
236 chip  1.39     CIMStatusCode code,
237 kumpf 1.37     const String& message,
238 mike  1.22     const char* file,
239 kumpf 1.31     Uint32 line)
240 mike  1.22 {
241                String tmp = file;
242                tmp.append("(");
243                char buffer[32];
244                sprintf(buffer, "%d", line);
245                tmp.append(buffer);
246                tmp.append("): ");
247 kumpf 1.41     tmp.append(_makeCIMExceptionDescription(code, message));
248 mike  1.22     return tmp;
249            }
250            
251            CIMException::CIMException(
252 chip  1.39     CIMStatusCode code,
253 kumpf 1.37     const String& message,
254 mike  1.22     const char* file,
255 kumpf 1.31     Uint32 line)
256 chip  1.39     :
257 kumpf 1.37     Exception(message),
258 kumpf 1.31     _code(code),
259                _file(file),
260                _line(line)
261 mike  1.22 {
262            
263 kumpf 1.32 }
264            
265 kumpf 1.37 //
266            // Returns a description string fit for human consumption
267            //
268            String CIMException::getDescription() const
269            {
270            #ifdef DEBUG_CIMEXCEPTION
271                return getTraceDescription();
272            #else
273                return _makeCIMExceptionDescription(_code, getMessage());
274            #endif
275            }
276            
277            //
278            // Returns a description string with filename and line number information
279 chip  1.39 // specifically for tracing.
280 kumpf 1.37 //
281            String CIMException::getTraceDescription() const
282            {
283                String traceDescription =
284                    _makeCIMExceptionDescription(_code, getMessage(), _file, _line);
285 chip  1.39 
286 kumpf 1.37     return traceDescription;
287 mike  1.22 }
288            
289 kumpf 1.38 void ThrowUninitializedHandle()
290 mike  1.22 {
291 kumpf 1.38     throw UninitializedHandle();
292 mike  1.22 }
293            
294            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2