(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.1  const char UnitializedHandle::MSG[] = "unitialized reference";
 70            
 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            const char NoSuchDirectory::MSG[] = "no such directory: ";
121            
122            const char ChangeDirectoryFailed::MSG[] = "failed to change directory: ";
123            
124            const char CannotCreateDirectory::MSG[] = "cannot create directory: ";
125            
126            const char NoSuchNameSpace::MSG[] = "no such namespace: ";
127            
128            const char CannotOpenFile::MSG[] = "cannot open file: ";
129            
130            const char NotImplemented::MSG[] = "not implemented: ";
131 mike  1.1  
132            const char FailedToRemoveDirectory::MSG[] = "failed to remove directory: ";
133            
134            const char FailedToRemoveFile::MSG[] = "failed to remove file: ";
135            
136            const char StackUnderflow::MSG[] = "stack overflow";
137            
138            const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
139            
140            const char BadDateTimeFormat::MSG[] = "bad datetime format";
141            
142            const char IncompatibleTypes::MSG[] = "incompatible types";
143            
144            const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
145 mike  1.4  
146 mike  1.11 const char IllformedObjectName::MSG[] = "illformed object name: ";
147 mike  1.5  
148            const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";
149            
150            const char DynamicLookupFailed::MSG[] = 
151                "lookup of symbol in dynamic library failed: ";
152 mike  1.6  
153            const char CannotOpenDirectory::MSG[] = "cannot open directory: ";
154 mike  1.1  
155            ////////////////////////////////////////////////////////////////////////////////
156            //
157 mike  1.8  // CIMException
158 mike  1.1  //
159            ////////////////////////////////////////////////////////////////////////////////
160            
161            static char* _cimMessages[] =
162            {
163 mike  1.12     "SUCCESS: successful",
164 mike  1.1  
165 mike  1.12     "FAILED: A general error occurred that is not covered by a more specific "
166                "error code",
167 mike  1.1  
168 mike  1.12     "ACCESS_DENIED: Access to a CIM resource was not available to the client",
169 mike  1.1  
170 mike  1.12     "INVALID_NAMESPACE: The target namespace does not exist",
171 mike  1.1  
172 mike  1.12     "INVALID_PARAMETER: One or more parameter values passed to the method "
173                "were invalid",
174 mike  1.1  
175 mike  1.12     "INVALID_CLASS: The specified class does not exist",
176 mike  1.1  
177 mike  1.12     "NOT_FOUND: The requested object could not be found",
178 mike  1.1  
179 mike  1.12     "NOT_SUPPORTED: The requested operation is not supported",
180 mike  1.1  
181 mike  1.12     "CLASS_HAS_CHILDREN: Operation cannot be carried out on this class since "
182                "it has subclasses",
183 mike  1.1  
184 mike  1.12     "CLASS_HAS_INSTANCES: Operation cannot be carried out on this class since "
185                "it has instances",
186 mike  1.1  
187 mike  1.12     "INVALID_SUPERCLASS: Operation cannot be carried out since the specified "
188                "superclass does not exist",
189 mike  1.1  
190 mike  1.12     "ALREADY_EXISTS: Operation cannot be carried out because an object already "
191                "exists",
192 mike  1.1  
193 mike  1.12     "NO_SUCH_PROPERTY: The specified property does not exist",
194 mike  1.1  
195 mike  1.12     "TYPE_MISMATCH: The value supplied is incompatible with the type",
196 mike  1.1  
197 mike  1.12     "QUERY_LANGUAGE_NOT_SUPPORTED: The query language is not recognized or "
198                "supported",
199 mike  1.1  
200 mike  1.12     "INVALID_QUERY: The query is not valid for the specified query language",
201 mike  1.1  
202 mike  1.12     "METHOD_NOT_AVAILABLE: The extrinsic method could not be executed",
203 mike  1.1  
204 mike  1.12     "METHOD_NOT_FOUND: The specified extrinsic method does not exist"
205 mike  1.1  };
206            
207 mike  1.8  static String _makeCIMExceptionMessage(
208                CIMException::Code code, 
209 mike  1.12     const char* file,
210                Uint32 line,
211                const String& extraMessage)
212 mike  1.8  {
213 mike  1.12     String tmp = file;
214                tmp.append("(");
215                char buffer[32];
216                sprintf(buffer, "%d", line);
217                tmp.append(buffer);
218                tmp.append("): ");
219            
220                tmp.append(_cimMessages[Uint32(code)]);
221                tmp.append(": \"");
222 mike  1.8      tmp.append(extraMessage);
223 mike  1.12     tmp.append("\"");
224 mike  1.8      return tmp;
225            }
226            
227            CIMException::CIMException(
228                CIMException::Code code, 
229 mike  1.12     const char* file,
230                Uint32 line,
231                const String& extraMessage)
232                : Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)),
233                _code(code)
234 mike  1.1  {
235            
236            }
237            
238 mike  1.8  const char* CIMException::codeToString(CIMException::Code code)
239 mike  1.1  {
240                return _cimMessages[Uint32(code)];
241            }
242            
243 mike  1.13 void ThrowUnitializedHandle()
244            {
245                throw UnitializedHandle();
246            }
247            
248 mike  1.1  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2