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

  1 mike  1.10 //%/////////////////////////////////////////////////////////////////////////////
  2 mike  1.1  //
  3            // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
  4            //
  5            // Permission is hereby granted, free of charge, to any person obtaining a
  6            // copy of this software and associated documentation files (the "Software"),
  7            // to deal in the Software without restriction, including without limitation
  8            // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9            // and/or sell copies of the Software, and to permit persons to whom the
 10            // Software is furnished to do so, subject to the following conditions:
 11            //
 12            // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 13            // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 14            // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 15            // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 16            // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 17            // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 18            // DEALINGS IN THE SOFTWARE.
 19            //
 20 mike  1.10 //==============================================================================
 21 mike  1.1  //
 22 mike  1.10 // Author: Mike Brasher (mbrasher@bmc.com)
 23 mike  1.1  //
 24 mike  1.10 // Modified By:
 25 mike  1.9  //
 26 mike  1.10 //%/////////////////////////////////////////////////////////////////////////////
 27 mike  1.1  
 28            #include <cstdio>
 29            #include "Exception.h"
 30            
 31            PEGASUS_NAMESPACE_BEGIN
 32            
 33            Exception::Exception(const String& message) : _message(message) 
 34            { 
 35            
 36            }
 37            
 38            Exception::Exception(const char* message) : _message(message) 
 39            {
 40            
 41            }
 42            
 43            Exception::~Exception()
 44            {
 45            
 46            }
 47            
 48 mike  1.1  AssertionFailureException::AssertionFailureException(
 49                const char* file, 
 50                size_t line,
 51                const String& message) : Exception(String())
 52            {
 53                char lineStr[32];
 54                sprintf(lineStr, "%d", line);
 55            
 56                _message = file;
 57                _message.append("(");
 58                _message.append(lineStr);
 59                _message.append("): ");
 60                _message.append(message);
 61            }
 62            
 63            const char OutOfBounds::MSG[] = "out of bounds";
 64            
 65            const char AlreadyExists::MSG[] = "already exists: ";
 66            
 67            const char NullPointer::MSG[] = "null pointer";
 68            
 69 mike  1.16 const char UnitializedHandle::MSG[] = "unitialized handle";
 70 mike  1.1  
 71            const char IllegalName::MSG[] = "illegal CIM name";
 72            
 73            const char InvalidPropertyOverride::MSG[] = "invalid property override: ";
 74            
 75            const char InvalidMethodOverride::MSG[] = "invalid method override: ";
 76            
 77            const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";
 78            
 79            const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";
 80            
 81            const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";
 82            
 83 mike  1.4  const char BadQualifierType::MSG[] = 
 84 mike  1.7      "CIMType of qualifier different than its declaration: ";
 85 mike  1.4  
 86 mike  1.1  const char NullType::MSG[] = "type is null";
 87            
 88            const char AddedReferenceToClass::MSG[] = 
 89                "attempted to add reference to a non-association class: ";
 90            
 91            const char ClassAlreadyResolved::MSG[] = 
 92                "attempt to resolve a class that is already resolved: ";
 93            
 94            const char ClassNotResolved::MSG[] = 
 95                "class is not yet resolved: ";
 96            
 97            const char InstanceAlreadyResolved::MSG[] = 
 98                "attempted to resolve a instance that is already resolved";
 99            
100            const char InstantiatedAbstractClass::MSG[] = 
101                "attempted to instantiated an abstract class";
102            
103            const char NoSuchProperty::MSG[] = "no such property: ";
104            
105            const char TruncatedCharacter::MSG[] = 
106                "truncated character during conversion from Char16 to char";
107 mike  1.1  
108            const char ExpectedReferenceValue::MSG[] = 
109 mike  1.7      "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "
110 mike  1.1      "in this context";
111            
112            const char MissingReferenceClassName::MSG[] = "missing reference class name";
113            
114            const char IllegalTypeTag::MSG[] = "illegal type tag";
115            
116            const char TypeMismatch::MSG[] = "type mismatch";
117            
118            const char NoSuchFile::MSG[] = "no such file: ";
119            
120 karl  1.15 const char CannotBindToAddress::MSG[] = "cannot bind to address: ";
121            
122 mike  1.1  const char NoSuchDirectory::MSG[] = "no such directory: ";
123            
124            const char ChangeDirectoryFailed::MSG[] = "failed to change directory: ";
125            
126            const char CannotCreateDirectory::MSG[] = "cannot create directory: ";
127            
128            const char NoSuchNameSpace::MSG[] = "no such namespace: ";
129            
130            const char CannotOpenFile::MSG[] = "cannot open file: ";
131            
132            const char NotImplemented::MSG[] = "not implemented: ";
133            
134            const char FailedToRemoveDirectory::MSG[] = "failed to remove directory: ";
135            
136            const char FailedToRemoveFile::MSG[] = "failed to remove file: ";
137            
138            const char StackUnderflow::MSG[] = "stack overflow";
139            
140            const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
141            
142            const char BadDateTimeFormat::MSG[] = "bad datetime format";
143 mike  1.1  
144            const char IncompatibleTypes::MSG[] = "incompatible types";
145            
146            const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
147 mike  1.4  
148 mike  1.11 const char IllformedObjectName::MSG[] = "illformed object name: ";
149 mike  1.5  
150            const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";
151            
152            const char DynamicLookupFailed::MSG[] = 
153                "lookup of symbol in dynamic library failed: ";
154 mike  1.6  
155            const char CannotOpenDirectory::MSG[] = "cannot open directory: ";
156 mike  1.1  
157            ////////////////////////////////////////////////////////////////////////////////
158            //
159 mike  1.8  // CIMException
160 mike  1.1  //
161            ////////////////////////////////////////////////////////////////////////////////
162            
163 mike  1.14 static const char* _cimMessages[] =
164 mike  1.1  {
165 mike  1.12     "SUCCESS: successful",
166 mike  1.1  
167 mike  1.12     "FAILED: A general error occurred that is not covered by a more specific "
168                "error code",
169 mike  1.1  
170 mike  1.12     "ACCESS_DENIED: Access to a CIM resource was not available to the client",
171 mike  1.1  
172 mike  1.12     "INVALID_NAMESPACE: The target namespace does not exist",
173 mike  1.1  
174 mike  1.12     "INVALID_PARAMETER: One or more parameter values passed to the method "
175                "were invalid",
176 mike  1.1  
177 mike  1.12     "INVALID_CLASS: The specified class does not exist",
178 mike  1.1  
179 mike  1.12     "NOT_FOUND: The requested object could not be found",
180 mike  1.1  
181 mike  1.12     "NOT_SUPPORTED: The requested operation is not supported",
182 mike  1.1  
183 mike  1.12     "CLASS_HAS_CHILDREN: Operation cannot be carried out on this class since "
184                "it has subclasses",
185 mike  1.1  
186 mike  1.12     "CLASS_HAS_INSTANCES: Operation cannot be carried out on this class since "
187                "it has instances",
188 mike  1.1  
189 mike  1.12     "INVALID_SUPERCLASS: Operation cannot be carried out since the specified "
190                "superclass does not exist",
191 mike  1.1  
192 mike  1.12     "ALREADY_EXISTS: Operation cannot be carried out because an object already "
193                "exists",
194 mike  1.1  
195 mike  1.12     "NO_SUCH_PROPERTY: The specified property does not exist",
196 mike  1.1  
197 mike  1.12     "TYPE_MISMATCH: The value supplied is incompatible with the type",
198 mike  1.1  
199 mike  1.12     "QUERY_LANGUAGE_NOT_SUPPORTED: The query language is not recognized or "
200                "supported",
201 mike  1.1  
202 mike  1.12     "INVALID_QUERY: The query is not valid for the specified query language",
203 mike  1.1  
204 mike  1.12     "METHOD_NOT_AVAILABLE: The extrinsic method could not be executed",
205 mike  1.1  
206 mike  1.12     "METHOD_NOT_FOUND: The specified extrinsic method does not exist"
207 mike  1.1  };
208            
209 mike  1.8  static String _makeCIMExceptionMessage(
210                CIMException::Code code, 
211 mike  1.12     const char* file,
212                Uint32 line,
213                const String& extraMessage)
214 mike  1.8  {
215 mike  1.12     String tmp = file;
216                tmp.append("(");
217                char buffer[32];
218                sprintf(buffer, "%d", line);
219                tmp.append(buffer);
220                tmp.append("): ");
221            
222                tmp.append(_cimMessages[Uint32(code)]);
223                tmp.append(": \"");
224 mike  1.8      tmp.append(extraMessage);
225 mike  1.12     tmp.append("\"");
226 mike  1.8      return tmp;
227            }
228            
229            CIMException::CIMException(
230                CIMException::Code code, 
231 mike  1.12     const char* file,
232                Uint32 line,
233                const String& extraMessage)
234                : Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)),
235                _code(code)
236 mike  1.1  {
237            
238            }
239            
240 mike  1.8  const char* CIMException::codeToString(CIMException::Code code)
241 mike  1.1  {
242                return _cimMessages[Uint32(code)];
243            }
244            
245 mike  1.13 void ThrowUnitializedHandle()
246            {
247                throw UnitializedHandle();
248            }
249            
250 mike  1.1  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2