1 karl 1.14 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.12 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.9 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.12 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.13 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.14 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.3 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 kumpf 1.1 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
|
21 kumpf 1.3 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 kumpf 1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.3 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 kumpf 1.1 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
33 //
|
34 kumpf 1.7 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
35 // (carolann_graves@hp.com)
36 //
|
37 kumpf 1.1 //%/////////////////////////////////////////////////////////////////////////////
38
39 #include <cstdio>
40 #include "CIMClientException.h"
41 #include <Pegasus/Common/Tracer.h>
|
42 kumpf 1.7 #include <Pegasus/Common/ExceptionRep.h>
|
43 kumpf 1.1
44 PEGASUS_NAMESPACE_BEGIN
45
46 ////////////////////////////////////////////////////////////////////////////////
47 //
48 // CIMClientMalformedHTTPException
49 //
50 ////////////////////////////////////////////////////////////////////////////////
51
52 CIMClientMalformedHTTPException::CIMClientMalformedHTTPException(
53 const String& message)
|
54 kumpf 1.5 : Exception(message)
|
55 kumpf 1.1 {
56 }
57
58
59 ////////////////////////////////////////////////////////////////////////////////
60 //
|
61 kumpf 1.6 // CIMClientHTTPErrorException
|
62 kumpf 1.1 //
63 ////////////////////////////////////////////////////////////////////////////////
64
|
65 kumpf 1.7 class CIMClientHTTPErrorExceptionRep : public ExceptionRep
66 {
67 public:
68 Uint32 httpStatusCode;
|
69 kumpf 1.10 String reasonPhrase;
|
70 kumpf 1.7 String cimError;
|
71 kumpf 1.8 String cimErrorDetail;
|
72 kumpf 1.7 };
73
|
74 kumpf 1.1 static String _makeHTTPErrorMessage(
75 Uint32 httpStatusCode,
|
76 kumpf 1.10 const String& reasonPhrase,
|
77 kumpf 1.1 const String& cimError,
|
78 kumpf 1.8 const String& cimErrorDetail)
|
79 kumpf 1.1 {
|
80 kumpf 1.10 String tmp = "HTTP Error (";
|
81 kumpf 1.1 char buffer[32];
82 sprintf(buffer, "%u", httpStatusCode);
83 tmp.append(buffer);
|
84 kumpf 1.10 if (reasonPhrase != String::EMPTY)
85 {
86 tmp.append(" ");
87 tmp.append(reasonPhrase);
88 }
|
89 kumpf 1.1 tmp.append(")");
90
|
91 kumpf 1.8 if ((cimError != String::EMPTY) || (cimErrorDetail != String::EMPTY))
|
92 kumpf 1.1 {
93 tmp.append(":");
94 if (cimError != String::EMPTY)
95 {
96 tmp.append(" CIMError = \"");
97 tmp.append(cimError);
98 tmp.append("\"");
99 }
|
100 kumpf 1.8 if (cimErrorDetail != String::EMPTY)
|
101 kumpf 1.1 {
102 tmp.append(" Detail = \"");
|
103 kumpf 1.8 tmp.append(cimErrorDetail);
|
104 kumpf 1.1 tmp.append("\"");
105 }
106 }
107 tmp.append(".");
108 return tmp;
109 }
110
|
111 kumpf 1.6 CIMClientHTTPErrorException::CIMClientHTTPErrorException(
|
112 kumpf 1.1 Uint32 httpStatusCode,
113 const String& cimError,
|
114 kumpf 1.8 const String& cimErrorDetail)
|
115 kumpf 1.1 {
|
116 kumpf 1.7 CIMClientHTTPErrorExceptionRep * tmp =
117 new CIMClientHTTPErrorExceptionRep ();
|
118 kumpf 1.10 tmp->message = _makeHTTPErrorMessage (httpStatusCode, String::EMPTY,
119 cimError, cimErrorDetail);
120 tmp->httpStatusCode = httpStatusCode;
121 tmp->reasonPhrase = String::EMPTY;
122 tmp->cimError = cimError;
123 tmp->cimErrorDetail = cimErrorDetail;
124 _rep = tmp;
125 }
126
127 CIMClientHTTPErrorException::CIMClientHTTPErrorException(
128 Uint32 httpStatusCode,
129 const String& reasonPhrase,
130 const String& cimError,
131 const String& cimErrorDetail)
132 {
133 CIMClientHTTPErrorExceptionRep * tmp =
134 new CIMClientHTTPErrorExceptionRep ();
135 tmp->message = _makeHTTPErrorMessage (httpStatusCode, reasonPhrase,
136 cimError, cimErrorDetail);
|
137 kumpf 1.7 tmp->httpStatusCode = httpStatusCode;
|
138 kumpf 1.10 tmp->reasonPhrase = reasonPhrase;
|
139 kumpf 1.7 tmp->cimError = cimError;
|
140 kumpf 1.8 tmp->cimErrorDetail = cimErrorDetail;
|
141 kumpf 1.7 _rep = tmp;
|
142 kumpf 1.1 }
143
|
144 kumpf 1.6 CIMClientHTTPErrorException::CIMClientHTTPErrorException(
145 const CIMClientHTTPErrorException& httpError)
|
146 david.dillard 1.11 : Exception(*this)
|
147 kumpf 1.7 {
148 CIMClientHTTPErrorExceptionRep * tmp =
149 new CIMClientHTTPErrorExceptionRep ();
150 tmp->message = httpError._rep->message;
151 CIMClientHTTPErrorExceptionRep * rep;
152 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(httpError._rep);
153 tmp->httpStatusCode = rep->httpStatusCode;
|
154 kumpf 1.10 tmp->reasonPhrase = rep->reasonPhrase;
|
155 kumpf 1.7 tmp->cimError = rep->cimError;
|
156 kumpf 1.8 tmp->cimErrorDetail = rep->cimErrorDetail;
|
157 kumpf 1.7 _rep = tmp;
158 }
159
160 CIMClientHTTPErrorException::~CIMClientHTTPErrorException()
|
161 kumpf 1.1 {
162 }
163
|
164 kumpf 1.6 Uint32 CIMClientHTTPErrorException::getCode() const
|
165 kumpf 1.1 {
|
166 kumpf 1.7 CIMClientHTTPErrorExceptionRep* rep;
167 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
168 return rep->httpStatusCode;
|
169 kumpf 1.1 }
170
|
171 kumpf 1.6 String CIMClientHTTPErrorException::getCIMError() const
|
172 kumpf 1.1 {
|
173 kumpf 1.7 CIMClientHTTPErrorExceptionRep* rep;
174 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
175 return rep->cimError;
|
176 kumpf 1.1 }
177
|
178 kumpf 1.8 String CIMClientHTTPErrorException::getCIMErrorDetail() const
|
179 kumpf 1.1 {
|
180 kumpf 1.7 CIMClientHTTPErrorExceptionRep* rep;
181 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
|
182 kumpf 1.8 return rep->cimErrorDetail;
|
183 kumpf 1.1 }
184
185
186 ////////////////////////////////////////////////////////////////////////////////
187 //
188 // CIMClientXmlException
189 //
190 ////////////////////////////////////////////////////////////////////////////////
191
192 CIMClientXmlException::CIMClientXmlException(const String& message)
|
193 kumpf 1.5 : Exception(message)
|
194 kumpf 1.1 {
195 }
196
197
198 ////////////////////////////////////////////////////////////////////////////////
199 //
200 // CIMClientResponseException
201 //
202 ////////////////////////////////////////////////////////////////////////////////
203
204 CIMClientResponseException::CIMClientResponseException(const String& message)
|
205 kumpf 1.5 : Exception(message)
|
206 kumpf 1.1 {
207 }
208
209 PEGASUS_NAMESPACE_END
|