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
LIBZYPP_NG_EXPORT
#define LIBZYPP_NG_EXPORT
Definition: zyppglobal.h:7
ZYPP_FWD_DECLARE_PRIVATE
#define ZYPP_FWD_DECLARE_PRIVATE(Class)
Definition: zyppglobal.h:28
zyppng::NetworkRequestError::AuthFailed
Definition: networkrequesterror.h:38
zyppng::NetworkRequestError::TemporaryProblem
Definition: networkrequesterror.h:33
zyppng::NetworkRequestError::Type
Type
Definition: networkrequesterror.h:23
PtrTypes.h
zyppng::NetworkRequestError::ConnectionFailed
Definition: networkrequesterror.h:28
zyppng::NetworkRequestError::ExceededMaxLen
Definition: networkrequesterror.h:29
zyppng::NetworkRequestError::InvalidChecksum
Definition: networkrequesterror.h:30
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zyppng::NetworkRequestError::Cancelled
Definition: networkrequesterror.h:26
zyppng::NetworkRequestError::extraInfoValue
T extraInfoValue(const std::string &key, T &&defaultVal=T()) const
Definition: networkrequesterror.h:67
zyppng::NetworkRequestError::Timeout
Definition: networkrequesterror.h:34
zyppng::NetworkRequestErrorPrivate
Definition: networkrequesterror_p.h:6
zyppng::NetworkRequestError
The NetworkRequestError class Represents a error that occured in.
Definition: networkrequesterror.h:20
zyppglobal.h
zyppng::NetworkRequestError::NotFound
Definition: networkrequesterror.h:36
zyppng::NetworkRequestError::Forbidden
Definition: networkrequesterror.h:35
zyppng::NetworkRequestError::InternalError
Definition: networkrequesterror.h:25
zyppng::NetworkRequestError::Unauthorized
Definition: networkrequesterror.h:37
zypp::RWCOW_pointer
RW_pointer supporting 'copy on write' functionality.
Definition: PtrTypes.h:458
zyppng
Definition: abstracteventsource.cc:8
zyppng::NetworkRequestError::PeerCertificateInvalid
Definition: networkrequesterror.h:27
zyppng::NetworkRequestError::MalformedURL
Definition: networkrequesterror.h:32
zyppng::NetworkRequestError::UnsupportedProtocol
Definition: networkrequesterror.h:31