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

  1 mike  1.22 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3            // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4            //
  5            // Permission is hereby granted, free of charge, to any person obtaining a copy
  6 chip  1.39 // of this software and associated documentation files (the "Software"), to
  7            // deal in the Software without restriction, including without limitation the
  8            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9 mike  1.22 // sell copies of the Software, and to permit persons to whom the Software is
 10            // furnished to do so, subject to the following conditions:
 11 chip  1.39 //
 12            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 13 mike  1.22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15 chip  1.39 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 16            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 17            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 18 mike  1.22 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20            //
 21            //==============================================================================
 22            //
 23            // Author: Mike Brasher (mbrasher@bmc.com)
 24            //
 25 mike  1.23 // Modified By: Nag Boranna (nagaraja_boranna@hp.com)
 26            //
 27 kumpf 1.29 // Modified By: Jenny Yu (jenny_yu@am.exch.hp.com)
 28 mike  1.22 //
 29            //%/////////////////////////////////////////////////////////////////////////////
 30            
 31            #include <cstdio>
 32            #include "Exception.h"
 33 kumpf 1.33 #include "Tracer.h"
 34 mike  1.22 
 35            PEGASUS_NAMESPACE_BEGIN
 36            
 37 chip  1.39 Exception::Exception(const String& message) : _message(message)
 38            {
 39 mike  1.22 
 40            }
 41            
 42 chip  1.39 Exception::Exception(const char* message) : _message(message)
 43 mike  1.22 {
 44            
 45            }
 46            
 47            Exception::~Exception()
 48            {
 49            
 50            }
 51            
 52            AssertionFailureException::AssertionFailureException(
 53 chip  1.39     const char* file,
 54 mike  1.22     size_t line,
 55                const String& message) : Exception(String())
 56            {
 57                char lineStr[32];
 58 kumpf 1.30     sprintf(lineStr, "%u", line);
 59 mike  1.22 
 60                _message = file;
 61                _message.append("(");
 62                _message.append(lineStr);
 63                _message.append("): ");
 64                _message.append(message);
 65 kumpf 1.33 
 66                // ATTN-RK-P3-20020408: Should define a "test" trace component
 67                PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2, _message);
 68 mike  1.22 }
 69            
 70            const char OutOfBounds::MSG[] = "out of bounds";
 71            
 72            const char AlreadyExists::MSG[] = "already exists: ";
 73            
 74            const char NullPointer::MSG[] = "null pointer";
 75            
 76 kumpf 1.38 const char UninitializedHandle::MSG[] = "uninitialized handle";
 77 mike  1.22 
 78            const char IllegalName::MSG[] = "illegal CIM name";
 79            
 80            const char InvalidPropertyOverride::MSG[] = "invalid property override: ";
 81            
 82            const char InvalidMethodOverride::MSG[] = "invalid method override: ";
 83            
 84            const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";
 85            
 86            const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";
 87            
 88            const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";
 89            
 90 chip  1.39 const char BadQualifierType::MSG[] =
 91 mike  1.22     "CIMType of qualifier different than its declaration: ";
 92            
 93            const char NullType::MSG[] = "type is null";
 94            
 95 chip  1.39 const char AddedReferenceToClass::MSG[] =
 96 mike  1.22     "attempted to add reference to a non-association class: ";
 97            
 98 chip  1.39 const char ClassAlreadyResolved::MSG[] =
 99 mike  1.22     "attempt to resolve a class that is already resolved: ";
100            
101 chip  1.39 const char ClassNotResolved::MSG[] =
102 mike  1.22     "class is not yet resolved: ";
103            
104 chip  1.39 const char InstanceAlreadyResolved::MSG[] =
105 mike  1.22     "attempted to resolve a instance that is already resolved";
106            
107 chip  1.39 const char InstantiatedAbstractClass::MSG[] =
108 karl  1.28     "attempted to instantiate an abstract class ";
109 mike  1.22 
110            const char NoSuchProperty::MSG[] = "no such property: ";
111            
112 chip  1.39 const char TruncatedCharacter::MSG[] =
113 mike  1.22     "truncated character during conversion from Char16 to char";
114            
115 chip  1.39 const char ExpectedReferenceValue::MSG[] =
116 mike  1.22     "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "
117                "in this context";
118            
119            const char MissingReferenceClassName::MSG[] = "missing reference class name";
120            
121            const char IllegalTypeTag::MSG[] = "illegal type tag";
122            
123            const char TypeMismatch::MSG[] = "type mismatch";
124            
125 karl  1.25 const char CIMValueIsNull::MSG[] = "null CIMValue accessed";
126            
127            const char CIMValueInvalidType::MSG[] = "invalid CIMValue type";
128            
129 mike  1.24 const char DynamicCastFailed::MSG[] = "dynamic cast failed";
130            
131 mike  1.22 const char NoSuchFile::MSG[] = "no such file: ";
132            
133 mike  1.23 const char FileNotReadable::MSG[] = "file not readable: ";
134            
135 mike  1.22 const char CannotBindToAddress::MSG[] = "cannot bind to address: ";
136            
137            const char NoSuchDirectory::MSG[] = "no such directory: ";
138            
139            const char ChangeDirectoryFailed::MSG[] = "cannot change directory: ";
140            
141            const char CannotCreateDirectory::MSG[] = "cannot create directory: ";
142            
143            const char NoSuchNameSpace::MSG[] = "no such namespace: ";
144            
145            const char CannotOpenFile::MSG[] = "cannot open file: ";
146            
147            const char NotImplemented::MSG[] = "not implemented: ";
148            
149            const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";
150            
151            const char CannotRemoveFile::MSG[] = "cannot remove file: ";
152            
153            const char CannotRenameFile::MSG[] = "cannot rename file: ";
154            
155 mike  1.23 const char StackUnderflow::MSG[] = "stack underflow";
156            
157            const char StackOverflow::MSG[] = "stack overflow";
158 mike  1.22 
159            const char QueueUnderflow::MSG[] = "queue Underflow";
160            
161            const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
162            
163            const char BadDateTimeFormat::MSG[] = "bad datetime format";
164            
165            const char IncompatibleTypes::MSG[] = "incompatible types";
166            
167            const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
168            
169            const char IllformedObjectName::MSG[] = "illformed object name: ";
170            
171            const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";
172            
173 chip  1.39 const char DynamicLookupFailed::MSG[] =
174 mike  1.22     "lookup of symbol in dynamic library failed: ";
175            
176            const char CannotOpenDirectory::MSG[] = "cannot open directory: ";
177            
178            const char CorruptFile::MSG[] = "corrupt file: ";
179 mike  1.23 
180            const char BindFailed::MSG[] = "Bind failed: ";
181            
182            const char InvalidLocator::MSG[] = "Invalid locator: ";
183            
184            const char CannotCreateSocket::MSG[] = "Cannot create socket";
185            
186            const char CannotConnect::MSG[] = "Cannot connect to: ";
187            
188            const char UnexpectedFailure::MSG[] = "Unexpected failure";
189            
190            const char AlreadyConnected::MSG[] = "already connected";
191            
192            const char NotConnected::MSG[] = "not connected";
193            
194            const char TimedOut::MSG[] = "timed out";
195            
196            const char ParseError::MSG[] = "parse error: ";
197            
198            const char MissingNullTerminator::MSG[] = "missing null terminator: ";
199            
200 mike  1.23 const char SSL_Exception::MSG[] = "SSL Exception ";
201 mike  1.22 
202 kumpf 1.26 const char InvalidAuthHeader::MSG[] = "Invalid Authorization header";
203            
204            
205 mike  1.22 ////////////////////////////////////////////////////////////////////////////////
206            //
207            // CIMException
208            //
209            ////////////////////////////////////////////////////////////////////////////////
210            
211 kumpf 1.29 //
212 kumpf 1.37 // Creates a description without source file name and line number.
213 kumpf 1.29 //
214 kumpf 1.37 static String _makeCIMExceptionDescription(
215 kumpf 1.29     CIMStatusCode code,
216 kumpf 1.37     const String& message)
217 kumpf 1.29 {
218                String tmp;
219                tmp.append(CIMStatusCodeToString(code));
220                tmp.append(": \"");
221 kumpf 1.37     tmp.append(message);
222 kumpf 1.29     tmp.append("\"");
223                return tmp;
224            }
225            
226            //
227 kumpf 1.37 // Creates a description with source file name and line number.
228 kumpf 1.29 //
229 kumpf 1.37 static String _makeCIMExceptionDescription(
230 chip  1.39     CIMStatusCode code,
231 kumpf 1.37     const String& message,
232 mike  1.22     const char* file,
233 kumpf 1.31     Uint32 line)
234 mike  1.22 {
235                String tmp = file;
236                tmp.append("(");
237                char buffer[32];
238                sprintf(buffer, "%d", line);
239                tmp.append(buffer);
240                tmp.append("): ");
241            
242                tmp.append(CIMStatusCodeToString(code));
243                tmp.append(": \"");
244 kumpf 1.37     tmp.append(message);
245 mike  1.22     tmp.append("\"");
246                return tmp;
247            }
248            
249            CIMException::CIMException(
250 chip  1.39     CIMStatusCode code,
251 kumpf 1.37     const String& message,
252 mike  1.22     const char* file,
253 kumpf 1.31     Uint32 line)
254 chip  1.39     :
255 kumpf 1.37     Exception(message),
256 kumpf 1.31     _code(code),
257                _file(file),
258                _line(line)
259 mike  1.22 {
260            
261 kumpf 1.32 }
262            
263 kumpf 1.37 //
264            // Returns a description string fit for human consumption
265            //
266            String CIMException::getDescription() const
267            {
268            #ifdef DEBUG_CIMEXCEPTION
269                return getTraceDescription();
270            #else
271                return _makeCIMExceptionDescription(_code, getMessage());
272            #endif
273            }
274            
275            //
276            // Returns a description string with filename and line number information
277 chip  1.39 // specifically for tracing.
278 kumpf 1.37 //
279            String CIMException::getTraceDescription() const
280            {
281                String traceDescription =
282                    _makeCIMExceptionDescription(_code, getMessage(), _file, _line);
283 chip  1.39 
284 kumpf 1.37     return traceDescription;
285 mike  1.22 }
286            
287 kumpf 1.38 void ThrowUninitializedHandle()
288 mike  1.22 {
289 kumpf 1.38     throw UninitializedHandle();
290 mike  1.22 }
291            
292            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2