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