libzypp  17.35.14
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 
6 #include <boost/any.hpp>
7 #include <string>
8 #include <map>
9 
10 namespace zyppng {
11 
12 class NetworkRequest;
13 class NetworkRequestErrorPrivate;
14 
24  {
25  public:
26  enum Type {
27  NoError = 0,
28  InternalError, //< A error in the dispatcher that is not caused by the backend, check the error string
29  Cancelled, //< The request was cancelled
30  PeerCertificateInvalid, //< the peer certificate validation failed
31  ConnectionFailed, //< connecting to the server failed
32  ExceededMaxLen, //< the downloaded data exceeded the requested maximum lenght
33  InvalidChecksum, //< The downloaded data has a different checksum than expected
34  UnsupportedProtocol, //< The protocol given in the URL scheme is not supported by the backend
35  MalformedURL, //< The given URL is malformed
36  TemporaryProblem, //< There was a temporary problem with the server side
37  Timeout, //< The request timed out
38  Forbidden, //< Accessing the requested ressource on the server was forbidden
39  NotFound, //< The requested path in the URL does not exist on the server
40  Unauthorized, //<< No auth data given but authorization required
41  AuthFailed, //<< Auth data was given, but authorization failed
42  ServerReturnedError, //<< A error was returned by the server that is not explicitly handled
43  MissingData, //<< The download was a multirange download and we did not get all data that was requested, if that is returned some ranges might have been downloaded successful
44  RangeFail, //<< The download was a multirange download but the server decided to return the full file.
45  Http2Error, //<< Special error code for HTTP2 related errors
46  Http2StreamError, //<< Special error code for HTTP2 stream related errors
47  };
48 
50 
51  NetworkRequestError(const NetworkRequestError &) = default;
52  NetworkRequestError(NetworkRequestError &&) noexcept = default;
53  NetworkRequestError &operator=(const NetworkRequestError &) = default;
54  NetworkRequestError &operator=(NetworkRequestError &&) noexcept = default;
59  Type type () const;
60 
65  std::string toString () const;
66 
71  bool isError () const;
72 
77  template<typename T>
78  T extraInfoValue ( const std::string &key, T &&defaultVal = T() ) const {
79  auto &t = extraInfo();
80  auto it = t.find(key);
81  if ( it != t.end() ) {
82  try {
83  return boost::any_cast<T>( it->second );
84  } catch ( const boost::bad_any_cast &) { }
85  }
86  return defaultVal;
87  }
88 
92  const std::map<std::string, boost::any> &extraInfo () const;
93 
97  std::string nativeErrorString() const;
98 
99  protected:
101 
102  private:
105  };
106 }
107 
108 #endif
Definition: Arch.h:363
The NetworkRequestError class Represents a error that occured in.
#define ZYPP_DECLARE_PRIVATE(Class)
Definition: zyppglobal.h:87
#define LIBZYPP_NG_EXPORT
Definition: zyppglobal.h:8
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
RW_pointer supporting &#39;copy on write&#39; functionality.
Definition: PtrTypes.h:468