1 #ifndef ZYPP_NG_MEDIA_CURL_NETWORK_REQUEST_ERROR_H_INCLUDED
2 #define ZYPP_NG_MEDIA_CURL_NETWORK_REQUEST_ERROR_H_INCLUDED
4 #include <zypp/zyppng/base/zyppglobal.h>
5 #include <zypp/base/PtrTypes.h>
6 #include <boost/any.hpp>
13 class NetworkRequestErrorPrivate;
16 * @brief The NetworkRequestError class
17 * Represents a error that occured in \see NetworkDownloadRequest
18 * or \see NetworkRequestDispatcher
20 class LIBZYPP_NG_EXPORT NetworkRequestError
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
42 NetworkRequestError ();
46 * Returns the type of the error
52 * Returns a string representation of the error
54 std::string toString () const;
58 * Will return true if this is a actual error
60 bool isError () const;
63 * Tries to find \a key in the extraInfo map, if the key is not found
64 * or the value can not be converted to the requested type \a defaultVal is returned.
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() ) {
72 return boost::any_cast<T>( it->second );
73 } catch ( const boost::bad_any_cast &) { }
79 * Returns the error extraInfo map.
81 const std::map<std::string, boost::any> &extraInfo () const;
84 * Returns the string returned by the backend if available.
86 std::string nativeErrorString() const;
89 NetworkRequestError( NetworkRequestErrorPrivate &d );
92 ZYPP_FWD_DECLARE_PRIVATE(NetworkRequestError)
93 zypp::RWCOW_pointer<NetworkRequestErrorPrivate> d_ptr;