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 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include <cstdio>
35 #include "CIMClientException.h"
36 #include <Pegasus/Common/Tracer.h>
|
37 kumpf 1.7 #include <Pegasus/Common/ExceptionRep.h>
|
38 kumpf 1.1
39 PEGASUS_NAMESPACE_BEGIN
40
41 ////////////////////////////////////////////////////////////////////////////////
42 //
43 // CIMClientMalformedHTTPException
44 //
45 ////////////////////////////////////////////////////////////////////////////////
46
47 CIMClientMalformedHTTPException::CIMClientMalformedHTTPException(
48 const String& message)
|
49 kumpf 1.5 : Exception(message)
|
50 kumpf 1.15 {
|
51 kumpf 1.1 }
52
53
54 ////////////////////////////////////////////////////////////////////////////////
55 //
|
56 kumpf 1.6 // CIMClientHTTPErrorException
|
57 kumpf 1.1 //
58 ////////////////////////////////////////////////////////////////////////////////
59
|
60 kumpf 1.7 class CIMClientHTTPErrorExceptionRep : public ExceptionRep
61 {
62 public:
63 Uint32 httpStatusCode;
|
64 kumpf 1.10 String reasonPhrase;
|
65 kumpf 1.7 String cimError;
|
66 kumpf 1.8 String cimErrorDetail;
|
67 kumpf 1.7 };
68
|
69 kumpf 1.1 static String _makeHTTPErrorMessage(
|
70 kumpf 1.15 Uint32 httpStatusCode,
|
71 kumpf 1.10 const String& reasonPhrase,
|
72 kumpf 1.1 const String& cimError,
|
73 kumpf 1.8 const String& cimErrorDetail)
|
74 kumpf 1.1 {
|
75 kumpf 1.10 String tmp = "HTTP Error (";
|
76 kumpf 1.1 char buffer[32];
77 sprintf(buffer, "%u", httpStatusCode);
78 tmp.append(buffer);
|
79 kumpf 1.10 if (reasonPhrase != String::EMPTY)
80 {
81 tmp.append(" ");
82 tmp.append(reasonPhrase);
83 }
|
84 kumpf 1.1 tmp.append(")");
85
|
86 kumpf 1.8 if ((cimError != String::EMPTY) || (cimErrorDetail != String::EMPTY))
|
87 kumpf 1.1 {
88 tmp.append(":");
89 if (cimError != String::EMPTY)
90 {
91 tmp.append(" CIMError = \"");
92 tmp.append(cimError);
93 tmp.append("\"");
94 }
|
95 kumpf 1.8 if (cimErrorDetail != String::EMPTY)
|
96 kumpf 1.1 {
97 tmp.append(" Detail = \"");
|
98 kumpf 1.8 tmp.append(cimErrorDetail);
|
99 kumpf 1.1 tmp.append("\"");
100 }
101 }
102 tmp.append(".");
103 return tmp;
104 }
105
|
106 kumpf 1.6 CIMClientHTTPErrorException::CIMClientHTTPErrorException(
|
107 kumpf 1.15 Uint32 httpStatusCode,
|
108 kumpf 1.1 const String& cimError,
|
109 kumpf 1.8 const String& cimErrorDetail)
|
110 kumpf 1.1 {
|
111 kumpf 1.15 CIMClientHTTPErrorExceptionRep* tmp =
|
112 kumpf 1.7 new CIMClientHTTPErrorExceptionRep ();
|
113 kumpf 1.10 tmp->message = _makeHTTPErrorMessage (httpStatusCode, String::EMPTY,
114 cimError, cimErrorDetail);
115 tmp->httpStatusCode = httpStatusCode;
116 tmp->reasonPhrase = String::EMPTY;
117 tmp->cimError = cimError;
118 tmp->cimErrorDetail = cimErrorDetail;
119 _rep = tmp;
120 }
121
122 CIMClientHTTPErrorException::CIMClientHTTPErrorException(
|
123 kumpf 1.15 Uint32 httpStatusCode,
|
124 kumpf 1.10 const String& reasonPhrase,
125 const String& cimError,
126 const String& cimErrorDetail)
127 {
|
128 kumpf 1.15 CIMClientHTTPErrorExceptionRep* tmp =
|
129 kumpf 1.10 new CIMClientHTTPErrorExceptionRep ();
130 tmp->message = _makeHTTPErrorMessage (httpStatusCode, reasonPhrase,
131 cimError, cimErrorDetail);
|
132 kumpf 1.7 tmp->httpStatusCode = httpStatusCode;
|
133 kumpf 1.10 tmp->reasonPhrase = reasonPhrase;
|
134 kumpf 1.7 tmp->cimError = cimError;
|
135 kumpf 1.8 tmp->cimErrorDetail = cimErrorDetail;
|
136 kumpf 1.7 _rep = tmp;
|
137 kumpf 1.1 }
138
|
139 kumpf 1.6 CIMClientHTTPErrorException::CIMClientHTTPErrorException(
140 const CIMClientHTTPErrorException& httpError)
|
141 david.dillard 1.11 : Exception(*this)
|
142 kumpf 1.7 {
143 CIMClientHTTPErrorExceptionRep * tmp =
144 new CIMClientHTTPErrorExceptionRep ();
145 tmp->message = httpError._rep->message;
146 CIMClientHTTPErrorExceptionRep * rep;
147 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(httpError._rep);
148 tmp->httpStatusCode = rep->httpStatusCode;
|
149 kumpf 1.10 tmp->reasonPhrase = rep->reasonPhrase;
|
150 kumpf 1.7 tmp->cimError = rep->cimError;
|
151 kumpf 1.8 tmp->cimErrorDetail = rep->cimErrorDetail;
|
152 kumpf 1.7 _rep = tmp;
153 }
154
155 CIMClientHTTPErrorException::~CIMClientHTTPErrorException()
|
156 kumpf 1.1 {
157 }
158
|
159 kumpf 1.6 Uint32 CIMClientHTTPErrorException::getCode() const
|
160 kumpf 1.1 {
|
161 kumpf 1.7 CIMClientHTTPErrorExceptionRep* rep;
162 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
163 return rep->httpStatusCode;
|
164 kumpf 1.1 }
165
|
166 kumpf 1.6 String CIMClientHTTPErrorException::getCIMError() const
|
167 kumpf 1.1 {
|
168 kumpf 1.7 CIMClientHTTPErrorExceptionRep* rep;
169 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
170 return rep->cimError;
|
171 kumpf 1.1 }
172
|
173 kumpf 1.8 String CIMClientHTTPErrorException::getCIMErrorDetail() const
|
174 kumpf 1.1 {
|
175 kumpf 1.7 CIMClientHTTPErrorExceptionRep* rep;
176 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
|
177 kumpf 1.8 return rep->cimErrorDetail;
|
178 kumpf 1.1 }
179
180
181 ////////////////////////////////////////////////////////////////////////////////
182 //
183 // CIMClientXmlException
184 //
185 ////////////////////////////////////////////////////////////////////////////////
186
187 CIMClientXmlException::CIMClientXmlException(const String& message)
|
188 kumpf 1.5 : Exception(message)
|
189 kumpf 1.15 {
|
190 kumpf 1.1 }
191
192
193 ////////////////////////////////////////////////////////////////////////////////
194 //
195 // CIMClientResponseException
196 //
197 ////////////////////////////////////////////////////////////////////////////////
198
199 CIMClientResponseException::CIMClientResponseException(const String& message)
|
200 kumpf 1.5 : Exception(message)
|
201 kumpf 1.15 {
|
202 kumpf 1.1 }
203
204 PEGASUS_NAMESPACE_END
|