libzypp: zypp-curl/ng/network/networkrequesterror.h Source File

libzypp 17.36.6

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 Http2Error, //<< Special error code for HTTP2 related errors
46 Http2StreamError, //<< Special error code for HTTP2 stream related errors
47 };
48
49 NetworkRequestError ();
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:
100 NetworkRequestError( NetworkRequestErrorPrivate &d );
101
102 private:
103 ZYPP_DECLARE_PRIVATE(NetworkRequestError)
104 zypp::RWCOW_pointer<NetworkRequestErrorPrivate> d_ptr;
105 };
106}
107
108#endif
zyppng::NetworkRequestErrorPrivate
Definition networkrequesterror_p.h:23
zyppng::NetworkRequestError
The NetworkRequestError class Represents a error that occured in.
Definition networkrequesterror.h:24
zyppng::NetworkRequestError::NetworkRequestError
NetworkRequestError(NetworkRequestError &&) noexcept=default
zyppng::NetworkRequestError::toString
std::string toString() const
toString Returns a string representation of the error
Definition networkrequesterror.cc:235
zyppng::NetworkRequestError::NetworkRequestError
NetworkRequestError(const NetworkRequestError &)=default
zyppng::NetworkRequestError::extraInfoValue
T extraInfoValue(const std::string &key, T &&defaultVal=T()) const
Definition networkrequesterror.h:78
zyppng::NetworkRequestError::extraInfo
const std::map< std::string, boost::any > & extraInfo() const
Definition networkrequesterror.cc:245
zyppng::NetworkRequestError::type
Type type() const
type Returns the type of the error
Definition networkrequesterror.cc:230
zyppng::NetworkRequestError::NetworkRequestError
NetworkRequestError()
Definition networkrequesterror.cc:226
zyppng::NetworkRequestError::Type
Type
Definition networkrequesterror.h:26
zyppng::NetworkRequestError::ServerReturnedError
@ ServerReturnedError
Definition networkrequesterror.h:42
zyppng::NetworkRequestError::Forbidden
@ Forbidden
Definition networkrequesterror.h:38
zyppng::NetworkRequestError::PeerCertificateInvalid
@ PeerCertificateInvalid
Definition networkrequesterror.h:30
zyppng::NetworkRequestError::UnsupportedProtocol
@ UnsupportedProtocol
Definition networkrequesterror.h:34
zyppng::NetworkRequestError::InternalError
@ InternalError
Definition networkrequesterror.h:28
zyppng::NetworkRequestError::ExceededMaxLen
@ ExceededMaxLen
Definition networkrequesterror.h:32
zyppng::NetworkRequestError::Unauthorized
@ Unauthorized
Definition networkrequesterror.h:40
zyppng::NetworkRequestError::MalformedURL
@ MalformedURL
Definition networkrequesterror.h:35
zyppng::NetworkRequestError::ConnectionFailed
@ ConnectionFailed
Definition networkrequesterror.h:31
zyppng::NetworkRequestError::RangeFail
@ RangeFail
Definition networkrequesterror.h:44
zyppng::NetworkRequestError::AuthFailed
@ AuthFailed
Definition networkrequesterror.h:41
zyppng::NetworkRequestError::Timeout
@ Timeout
Definition networkrequesterror.h:37
zyppng::NetworkRequestError::Http2Error
@ Http2Error
Definition networkrequesterror.h:45
zyppng::NetworkRequestError::MissingData
@ MissingData
Definition networkrequesterror.h:43
zyppng::NetworkRequestError::NoError
@ NoError
Definition networkrequesterror.h:27
zyppng::NetworkRequestError::NotFound
@ NotFound
Definition networkrequesterror.h:39
zyppng::NetworkRequestError::Cancelled
@ Cancelled
Definition networkrequesterror.h:29
zyppng::NetworkRequestError::Http2StreamError
@ Http2StreamError
Definition networkrequesterror.h:46
zyppng::NetworkRequestError::TemporaryProblem
@ TemporaryProblem
Definition networkrequesterror.h:36
zyppng::NetworkRequestError::InvalidChecksum
@ InvalidChecksum
Definition networkrequesterror.h:33
zyppng::NetworkRequestError::isError
bool isError() const
isError Will return true if this is a actual error
Definition networkrequesterror.cc:240
zyppng::NetworkRequestError::d_ptr
zypp::RWCOW_pointer< NetworkRequestErrorPrivate > d_ptr
Definition networkrequesterror.h:104
zyppng::NetworkRequest
Definition request.h:43
std
Definition Arch.h:364
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zyppng
Definition MediaCurl2.h:22
zypp::RWCOW_pointer
RW_pointer supporting 'copy on write' functionality.
Definition PtrTypes.h:469
PtrTypes.h
zyppglobal.h
ZYPP_DECLARE_PRIVATE
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:87
LIBZYPP_NG_EXPORT
#define LIBZYPP_NG_EXPORT
Definition zyppglobal.h:8