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

  1 martin 1.17 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.18 //
  3 martin 1.17 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.18 //
 10 martin 1.17 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.18 //
 17 martin 1.17 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.18 //
 20 martin 1.17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.18 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.18 //
 28 martin 1.17 //////////////////////////////////////////////////////////////////////////
 29 kumpf  1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #include <cstdio>
 33             #include "CIMClientException.h"
 34             #include <Pegasus/Common/Tracer.h>
 35 kumpf  1.7  #include <Pegasus/Common/ExceptionRep.h>
 36 kumpf  1.1  
 37             PEGASUS_NAMESPACE_BEGIN
 38             
 39             ////////////////////////////////////////////////////////////////////////////////
 40             //
 41             // CIMClientMalformedHTTPException
 42             //
 43             ////////////////////////////////////////////////////////////////////////////////
 44             
 45             CIMClientMalformedHTTPException::CIMClientMalformedHTTPException(
 46                 const String& message)
 47 kumpf  1.5      : Exception(message)
 48 kumpf  1.15 {
 49 kumpf  1.1  }
 50             
 51             
 52             ////////////////////////////////////////////////////////////////////////////////
 53             //
 54 kumpf  1.6  // CIMClientHTTPErrorException
 55 kumpf  1.1  //
 56             ////////////////////////////////////////////////////////////////////////////////
 57             
 58 kumpf  1.7  class CIMClientHTTPErrorExceptionRep : public ExceptionRep
 59             {
 60             public:
 61 kumpf  1.16 
 62                 // Note:  The default implementations of the default constructor, copy
 63                 // constructor, and assignment operator are used.
 64             
 65 kumpf  1.7      Uint32 httpStatusCode;
 66 kumpf  1.10     String reasonPhrase;
 67 kumpf  1.7      String cimError;
 68 kumpf  1.8      String cimErrorDetail;
 69 kumpf  1.7  };
 70             
 71 kumpf  1.1  static String _makeHTTPErrorMessage(
 72 kumpf  1.15     Uint32 httpStatusCode,
 73 kumpf  1.10     const String& reasonPhrase,
 74 kumpf  1.1      const String& cimError,
 75 kumpf  1.8      const String& cimErrorDetail)
 76 kumpf  1.1  {
 77 kumpf  1.10     String tmp = "HTTP Error (";
 78 kumpf  1.1      char buffer[32];
 79                 sprintf(buffer, "%u", httpStatusCode);
 80                 tmp.append(buffer);
 81 kumpf  1.10     if (reasonPhrase != String::EMPTY)
 82                 {
 83                     tmp.append(" ");
 84                     tmp.append(reasonPhrase);
 85                 }
 86 kumpf  1.1      tmp.append(")");
 87             
 88 kumpf  1.8      if ((cimError != String::EMPTY) || (cimErrorDetail != String::EMPTY))
 89 kumpf  1.1      {
 90                     tmp.append(":");
 91                     if (cimError != String::EMPTY)
 92                     {
 93                         tmp.append(" CIMError = \"");
 94                         tmp.append(cimError);
 95                         tmp.append("\"");
 96                     }
 97 kumpf  1.8          if (cimErrorDetail != String::EMPTY)
 98 kumpf  1.1          {
 99                         tmp.append(" Detail = \"");
100 kumpf  1.8              tmp.append(cimErrorDetail);
101 kumpf  1.1              tmp.append("\"");
102                     }
103                 }
104                 tmp.append(".");
105                 return tmp;
106             }
107             
108 kumpf  1.6  CIMClientHTTPErrorException::CIMClientHTTPErrorException(
109 kumpf  1.15     Uint32 httpStatusCode,
110 kumpf  1.1      const String& cimError,
111 kumpf  1.8      const String& cimErrorDetail)
112 kumpf  1.16     : Exception()
113 kumpf  1.1  {
114 kumpf  1.15     CIMClientHTTPErrorExceptionRep* tmp =
115 kumpf  1.7          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 kumpf  1.15     Uint32 httpStatusCode,
127 kumpf  1.10     const String& reasonPhrase,
128                 const String& cimError,
129                 const String& cimErrorDetail)
130 kumpf  1.16     : Exception()
131 kumpf  1.10 {
132 kumpf  1.15     CIMClientHTTPErrorExceptionRep* tmp =
133 kumpf  1.10         new CIMClientHTTPErrorExceptionRep ();
134                 tmp->message = _makeHTTPErrorMessage (httpStatusCode, reasonPhrase,
135                                                       cimError, cimErrorDetail);
136 kumpf  1.7      tmp->httpStatusCode = httpStatusCode;
137 kumpf  1.10     tmp->reasonPhrase = reasonPhrase;
138 kumpf  1.7      tmp->cimError = cimError;
139 kumpf  1.8      tmp->cimErrorDetail = cimErrorDetail;
140 kumpf  1.7      _rep = tmp;
141 kumpf  1.1  }
142             
143 kumpf  1.6  CIMClientHTTPErrorException::CIMClientHTTPErrorException(
144                 const CIMClientHTTPErrorException& httpError)
145 kumpf  1.16     : Exception()
146 kumpf  1.7  {
147 kumpf  1.16     _rep = new CIMClientHTTPErrorExceptionRep(
148                     *reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(httpError._rep));
149 kumpf  1.7  }
150             
151             CIMClientHTTPErrorException::~CIMClientHTTPErrorException()
152 kumpf  1.1  {
153             }
154             
155 kumpf  1.16 CIMClientHTTPErrorException& CIMClientHTTPErrorException::operator=(
156                 const CIMClientHTTPErrorException& httpError)
157             {
158                 if (&httpError != this)
159                 {
160                     CIMClientHTTPErrorExceptionRep* left =
161                         reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(this->_rep);
162                     CIMClientHTTPErrorExceptionRep* right =
163                         reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(httpError._rep);
164                     *left = *right;
165                 }
166                 return *this;
167             }
168             
169 kumpf  1.6  Uint32 CIMClientHTTPErrorException::getCode() const
170 kumpf  1.1  {
171 kumpf  1.7      CIMClientHTTPErrorExceptionRep* rep;
172                 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
173                 return rep->httpStatusCode;
174 kumpf  1.1  }
175             
176 kumpf  1.6  String CIMClientHTTPErrorException::getCIMError() const
177 kumpf  1.1  {
178 kumpf  1.7      CIMClientHTTPErrorExceptionRep* rep;
179                 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
180                 return rep->cimError;
181 kumpf  1.1  }
182             
183 kumpf  1.8  String CIMClientHTTPErrorException::getCIMErrorDetail() const
184 kumpf  1.1  {
185 kumpf  1.7      CIMClientHTTPErrorExceptionRep* rep;
186                 rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
187 kumpf  1.8      return rep->cimErrorDetail;
188 kumpf  1.1  }
189             
190             
191             ////////////////////////////////////////////////////////////////////////////////
192             //
193             // CIMClientXmlException
194             //
195             ////////////////////////////////////////////////////////////////////////////////
196             
197             CIMClientXmlException::CIMClientXmlException(const String& message)
198 kumpf  1.5      : Exception(message)
199 kumpf  1.15 {
200 kumpf  1.1  }
201             
202             
203             ////////////////////////////////////////////////////////////////////////////////
204             //
205             // CIMClientResponseException
206             //
207             ////////////////////////////////////////////////////////////////////////////////
208             
209             CIMClientResponseException::CIMClientResponseException(const String& message)
210 kumpf  1.5      : Exception(message)
211 kumpf  1.15 {
212 kumpf  1.1  }
213             
214             PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2