libzypp  17.22.0
networkrequesterror.h
Go to the documentation of this file.
1 #ifndef ZYPP_NG_MEDIA_CURL_NETWORK_REQUEST_ERROR_H_INCLUDED
2 #define ZYPP_NG_MEDIA_CURL_NETWORK_REQUEST_ERROR_H_INCLUDED
3 
5 #include <zypp/base/PtrTypes.h>
6 #include <boost/any.hpp>
7 #include <string>
8 #include <map>
9 
10 namespace zyppng {
11 
12 class NetworkRequest;
13 class NetworkRequestErrorPrivate;
14 
21  {
22  public:
23  enum Type {
24  NoError = 0,
25  InternalError, //< A error in the dispatcher that is not caused by the backend, check the error string
26  Cancelled, //< The request was cancelled
27  PeerCertificateInvalid, //< the peer certificate validation failed
28  ConnectionFailed, //< connecting to the server failed
29  ExceededMaxLen, //< the downloaded data exceeded the requested maximum lenght
30  InvalidChecksum, //< The downloaded data has a different checksum than expected
31  UnsupportedProtocol, //< The protocol given in the URL scheme is not supported by the backend
32  MalformedURL, //< The given URL is malformed
33  TemporaryProblem, //< There was a temporary problem with the server side
34  Timeout, //< The request timed out
35  Forbidden, //< Accessing the requested ressource on the server was forbidden
36  NotFound, //< The requested path in the URL does not exist on the server
37  Unauthorized, //<< No auth data given but authorization required
38  AuthFailed, //<< Auth data was given, but authorization failed
39  ServerReturnedError //<< A error was returned by the server that is not explicitely handled
40  };
41 
43 
48  Type type () const;
49 
54  std::string toString () const;
55 
60  bool isError () const;
61 
66  template<typename T>
67  T extraInfoValue ( const std::string &key, T &&defaultVal = T() ) const {
68  auto &t = extraInfo();
69  auto it = t.find(key);
70  if ( it != t.end() ) {
71  try {
72  return boost::any_cast<T>( it->second );
73  } catch ( const boost::bad_any_cast &) { }
74  }
75  return defaultVal;
76  }
77 
81  const std::map<std::string, boost::any> &extraInfo () const;
82 
86  std::string nativeErrorString() const;
87 
88  protected:
90 
91  private:
94  };
95 }
96 
97 #endif
T extraInfoValue(const std::string &key, T &&defaultVal=T()) const
The NetworkRequestError class Represents a error that occured in.
#define ZYPP_FWD_DECLARE_PRIVATE(Class)
Definition: zyppglobal.h:28
#define LIBZYPP_NG_EXPORT
Definition: zyppglobal.h:7
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
RW_pointer supporting &#39;copy on write&#39; functionality.
Definition: PtrTypes.h:458