libzypp 17.37.17
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
10namespace zyppng {
11
12class NetworkRequest;
14
24 {
25 public:
26 enum Type {
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
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
The NetworkRequestError class Represents a error that occured in.
NetworkRequestError(NetworkRequestError &&) noexcept=default
std::string toString() const
toString Returns a string representation of the error
NetworkRequestError(const NetworkRequestError &)=default
T extraInfoValue(const std::string &key, T &&defaultVal=T()) const
const std::map< std::string, boost::any > & extraInfo() const
Type type() const
type Returns the type of the error
bool isError() const
isError Will return true if this is a actual error
zypp::RWCOW_pointer< NetworkRequestErrorPrivate > d_ptr
Definition Arch.h:364
Easy-to use interface to the ZYPP dependency resolver.
RW_pointer supporting 'copy on write' functionality.
Definition PtrTypes.h:469
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:87
#define LIBZYPP_NG_EXPORT
Definition zyppglobal.h:8