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

  1 mike  1.18 //%/////////////////////////////////////////////////////////////////////////////
  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            // 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            // 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            // 
 12            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13            // 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            // 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            // 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 mike  1.18 //
 23            // Author: Mike Brasher (mbrasher@bmc.com)
 24            //
 25            // Modified By:
 26            //
 27            //%/////////////////////////////////////////////////////////////////////////////
 28            
 29            #include <cstdio>
 30            #include "Exception.h"
 31            
 32            PEGASUS_NAMESPACE_BEGIN
 33            
 34            Exception::Exception(const String& message) : _message(message) 
 35            { 
 36            
 37            }
 38            
 39            Exception::Exception(const char* message) : _message(message) 
 40            {
 41            
 42            }
 43 mike  1.18 
 44            Exception::~Exception()
 45            {
 46            
 47            }
 48            
 49            AssertionFailureException::AssertionFailureException(
 50                const char* file, 
 51                size_t line,
 52                const String& message) : Exception(String())
 53            {
 54                char lineStr[32];
 55                sprintf(lineStr, "%d", line);
 56            
 57                _message = file;
 58                _message.append("(");
 59                _message.append(lineStr);
 60                _message.append("): ");
 61                _message.append(message);
 62            }
 63            
 64 mike  1.18 const char OutOfBounds::MSG[] = "out of bounds";
 65            
 66            const char AlreadyExists::MSG[] = "already exists: ";
 67            
 68            const char NullPointer::MSG[] = "null pointer";
 69            
 70            const char UnitializedHandle::MSG[] = "unitialized handle";
 71            
 72            const char IllegalName::MSG[] = "illegal CIM name";
 73            
 74            const char InvalidPropertyOverride::MSG[] = "invalid property override: ";
 75            
 76            const char InvalidMethodOverride::MSG[] = "invalid method override: ";
 77            
 78            const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";
 79            
 80            const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";
 81            
 82            const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";
 83            
 84            const char BadQualifierType::MSG[] = 
 85 mike  1.18     "CIMType of qualifier different than its declaration: ";
 86            
 87            const char NullType::MSG[] = "type is null";
 88            
 89            const char AddedReferenceToClass::MSG[] = 
 90                "attempted to add reference to a non-association class: ";
 91            
 92            const char ClassAlreadyResolved::MSG[] = 
 93                "attempt to resolve a class that is already resolved: ";
 94            
 95            const char ClassNotResolved::MSG[] = 
 96                "class is not yet resolved: ";
 97            
 98            const char InstanceAlreadyResolved::MSG[] = 
 99                "attempted to resolve a instance that is already resolved";
100            
101            const char InstantiatedAbstractClass::MSG[] = 
102                "attempted to instantiated an abstract class";
103            
104            const char NoSuchProperty::MSG[] = "no such property: ";
105            
106 mike  1.18 const char TruncatedCharacter::MSG[] = 
107                "truncated character during conversion from Char16 to char";
108            
109            const char ExpectedReferenceValue::MSG[] = 
110                "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "
111                "in this context";
112            
113            const char MissingReferenceClassName::MSG[] = "missing reference class name";
114            
115            const char IllegalTypeTag::MSG[] = "illegal type tag";
116            
117            const char TypeMismatch::MSG[] = "type mismatch";
118            
119            const char NoSuchFile::MSG[] = "no such file: ";
120            
121            const char CannotBindToAddress::MSG[] = "cannot bind to address: ";
122            
123            const char NoSuchDirectory::MSG[] = "no such directory: ";
124            
125            const char ChangeDirectoryFailed::MSG[] = "cannot change directory: ";
126            
127 mike  1.18 const char CannotCreateDirectory::MSG[] = "cannot create directory: ";
128            
129            const char NoSuchNameSpace::MSG[] = "no such namespace: ";
130            
131            const char CannotOpenFile::MSG[] = "cannot open file: ";
132            
133            const char NotImplemented::MSG[] = "not implemented: ";
134            
135            const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";
136            
137            const char CannotRemoveFile::MSG[] = "cannot remove file: ";
138            
139            const char CannotRenameFile::MSG[] = "cannot rename file: ";
140            
141            const char StackUnderflow::MSG[] = "stack overflow";
142            
143            const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
144            
145            const char BadDateTimeFormat::MSG[] = "bad datetime format";
146            
147            const char IncompatibleTypes::MSG[] = "incompatible types";
148 mike  1.18 
149            const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
150            
151            const char IllformedObjectName::MSG[] = "illformed object name: ";
152            
153            const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";
154            
155            const char DynamicLookupFailed::MSG[] = 
156                "lookup of symbol in dynamic library failed: ";
157            
158            const char CannotOpenDirectory::MSG[] = "cannot open directory: ";
159            
160            const char CorruptFile::MSG[] = "corrupt file: ";
161            
162            ////////////////////////////////////////////////////////////////////////////////
163            //
164            // CIMException
165            //
166            ////////////////////////////////////////////////////////////////////////////////
167            
168            static const char* _cimMessages[] =
169 mike  1.18 {
170                "SUCCESS: successful",
171            
172                "FAILED: A general error occurred that is not covered by a more specific "
173                "error code",
174            
175                "ACCESS_DENIED: Access to a CIM resource was not available to the client",
176            
177                "INVALID_NAMESPACE: The target namespace does not exist",
178            
179                "INVALID_PARAMETER: One or more parameter values passed to the method "
180                "were invalid",
181            
182                "INVALID_CLASS: The specified class does not exist",
183            
184                "NOT_FOUND: The requested object could not be found",
185            
186                "NOT_SUPPORTED: The requested operation is not supported",
187            
188                "CLASS_HAS_CHILDREN: Operation cannot be carried out on this class since "
189                "it has subclasses",
190 mike  1.18 
191                "CLASS_HAS_INSTANCES: Operation cannot be carried out on this class since "
192                "it has instances",
193            
194                "INVALID_SUPERCLASS: Operation cannot be carried out since the specified "
195                "superclass does not exist",
196            
197                "ALREADY_EXISTS: Operation cannot be carried out because an object already "
198                "exists",
199            
200                "NO_SUCH_PROPERTY: The specified property does not exist",
201            
202                "TYPE_MISMATCH: The value supplied is incompatible with the type",
203            
204                "QUERY_LANGUAGE_NOT_SUPPORTED: The query language is not recognized or "
205                "supported",
206            
207                "INVALID_QUERY: The query is not valid for the specified query language",
208            
209                "METHOD_NOT_AVAILABLE: The extrinsic method could not be executed",
210            
211 mike  1.18     "METHOD_NOT_FOUND: The specified extrinsic method does not exist"
212            };
213            
214            static String _makeCIMExceptionMessage(
215                CIMException::Code code, 
216                const char* file,
217                Uint32 line,
218                const String& extraMessage)
219            {
220                String tmp = file;
221                tmp.append("(");
222                char buffer[32];
223                sprintf(buffer, "%d", line);
224                tmp.append(buffer);
225                tmp.append("): ");
226            
227                tmp.append(_cimMessages[Uint32(code)]);
228                tmp.append(": \"");
229                tmp.append(extraMessage);
230                tmp.append("\"");
231                return tmp;
232 mike  1.18 }
233            
234            CIMException::CIMException(
235                CIMException::Code code, 
236                const char* file,
237                Uint32 line,
238                const String& extraMessage)
239                : Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)),
240                _code(code)
241            {
242            
243            }
244            
245            const char* CIMException::codeToString(CIMException::Code code)
246            {
247                return _cimMessages[Uint32(code)];
248            }
249            
250            void ThrowUnitializedHandle()
251            {
252                throw UnitializedHandle();
253 mike  1.18 }
254            
255            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2