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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2