libzypp 17.31.7
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
4#include <zypp-core/zyppng/base/zyppglobal.h>
5#include <zypp-core/base/PtrTypes.h>
6#include <boost/any.hpp>
7#include <string>
8#include <map>
9
10namespace zyppng {
11
12class NetworkRequest;
13class NetworkRequestErrorPrivate;
14
23 class LIBZYPP_NG_EXPORT NetworkRequestError
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 };
46
48
53 Type type () const;
54
59 std::string toString () const;
60
65 bool isError () const;
66
71 template<typename T>
72 T extraInfoValue ( const std::string &key, T &&defaultVal = T() ) const {
73 auto &t = extraInfo();
74 auto it = t.find(key);
75 if ( it != t.end() ) {
76 try {
77 return boost::any_cast<T>( it->second );
78 } catch ( const boost::bad_any_cast &) { }
79 }
80 return defaultVal;
81 }
82
86 const std::map<std::string, boost::any> &extraInfo () const;
87
91 std::string nativeErrorString() const;
92
93 protected:
95
96 private:
97 ZYPP_DECLARE_PRIVATE(NetworkRequestError)
98 zypp::RWCOW_pointer<NetworkRequestErrorPrivate> d_ptr;
99 };
100}
101
102#endif
The NetworkRequestError class Represents a error that occured in.
T extraInfoValue(const std::string &key, T &&defaultVal=T()) const
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2