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