13#include <zypp-curl/auth/CurlAuthData> 
   45  std::map<std::string, boost::any> extraInfo;
 
   47  if ( nativeCode != 0 ) {
 
   49    const char *nativeErr = curl_easy_strerror( 
static_cast<CURLcode
>(nativeCode) );
 
   50    if ( nativeErr != 
nullptr )
 
   53    if ( !nativeError.empty() )
 
   56    extraInfo.insert( { 
"requestUrl", 
url } );
 
   57    extraInfo.insert( { 
"curlCode", nativeCode } );
 
   63      case CURLE_UNSUPPORTED_PROTOCOL:
 
   68          err += 
" or redirect (";
 
   73      case CURLE_URL_MALFORMAT: 
case CURLE_URL_MALFORMAT_USER:
 
   76      case CURLE_LOGIN_DENIED:
 
   79      case CURLE_HTTP_RETURNED_ERROR: {
 
   80        long httpReturnCode = 0;
 
   81        CURLcode infoRet = curl_easy_getinfo( req.
nativeHandle(),
 
   82          CURLINFO_RESPONSE_CODE,
 
   85        if ( infoRet == CURLE_OK ) {
 
   86          extraInfo.insert( { 
"responseCode", httpReturnCode } );
 
   89          switch ( httpReturnCode )
 
   92              long auth_info = CURLAUTH_NONE;
 
   95                curl_easy_getinfo(req.
nativeHandle(), CURLINFO_HTTPAUTH_AVAIL, &auth_info);
 
   97              if (infoRet == CURLE_OK) {
 
  115              err = 
zypp::str::form( 
_(
"Location '%s' is temporarily unaccessible."), 
url.asString().c_str() );
 
  119              err = 
zypp::str::form(
_(
"Timeout exceeded when accessing '%s'."), 
url.asString().c_str() );
 
  123              if ( 
url.getHost().find(
".suse.com") != std::string::npos )
 
  124                msg403 = 
_(
"Visit the SUSE Customer Center to check whether your registration is valid and has not expired.");
 
  125              else if (
url.asString().find(
"novell.com") != std::string::npos)
 
  126                msg403 = 
_(
"Visit the Novell Customer Center to check whether your registration is valid and has not expired.");
 
  147                                    "Unable to retrieve HTTP response\n"), 
url.asString().c_str() ) ;
 
  151      case CURLE_FTP_COULDNT_RETR_FILE:
 
  152#if CURLVERSION_AT_LEAST(7,16,0) 
  153      case CURLE_REMOTE_FILE_NOT_FOUND:
 
  155      case CURLE_FTP_ACCESS_DENIED:
 
  156      case CURLE_TFTP_NOTFOUND:
 
  159      case CURLE_BAD_PASSWORD_ENTERED:
 
  160      case CURLE_FTP_USER_PASSWORD_INCORRECT:
 
  163      case CURLE_COULDNT_RESOLVE_PROXY:
 
  164      case CURLE_COULDNT_RESOLVE_HOST:
 
  165      case CURLE_COULDNT_CONNECT:
 
  166      case CURLE_FTP_CANT_GET_HOST:
 
  169      case CURLE_WRITE_ERROR: {
 
  174      case CURLE_PARTIAL_FILE:
 
  177      case CURLE_OPERATION_TIMEDOUT:
 
  180      case CURLE_ABORTED_BY_CALLBACK:
 
  183      case CURLE_PEER_FAILED_VERIFICATION:
 
  189      case CURLE_HTTP2_STREAM:
 
 
  208  const char *nativeErr = curl_multi_strerror( 
static_cast<CURLMcode
>(nativeCode) );
 
  210  std::map<std::string, boost::any> extraInfo;
 
  211  extraInfo.insert( { 
"curlMCode", nativeCode } );
 
  214  if ( nativeErr == 
nullptr )
 
  215    err = 
"The dispatcher returned an unknown error";
 
  217    err = std::string( nativeErr );
 
 
  232  return d_func()->_errorCode;
 
 
  237  return d_func()->_errorMessage;
 
 
  242  return d_func()->_errorCode != 
NoError;
 
 
  247  return d_func()->_extraInfo;
 
 
  256      return "Internal Error";
 
  258      return "The request was cancelled";
 
  260      return "The request exceeded the maximum download size";
 
  262      return "The downloaded data did not result in a valid checksum";
 
  264      return "The peer certificate could not be verified";
 
  266      return "Connection failed";
 
  268      return "Unsupported protocol";
 
  272      return "Requested location is temporarily unaccessible.";
 
  274      return "Timeout reached";
 
  276      return "Access to requested URL is forbidden.";
 
  278      return "File not found";
 
  280      return "Authentication required but not provided.";
 
  282      return "Login failed.";
 
  284      return "Server returned an error for the given request.";
 
  286      return "Server did not send all requested ranges.";
 
  288      return "Invalid data from server, multipart was requested but there was no range status code.";
 
  290      return "Server returned a HTTP/2 error.";
 
  292      return "Server returned a HTTP/2 stream error.";
 
  294  return std::string();
 
 
  302  if ( it != d->_extraInfo.end() ) {
 
  304      return boost::any_cast<std::string>( it->second );
 
  305    } 
catch ( 
const boost::bad_any_cast &) { }
 
  309  if ( it != d->_extraInfo.end() ) {
 
  311      return boost::any_cast<std::string>( it->second );
 
  312    } 
catch ( 
const boost::bad_any_cast &) { }
 
  315  return std::string();
 
 
const char * c_str() const
String representation.
const std::string & asString() const
String representation.
static std::string typeToString(NetworkRequestError::Type t)
NetworkRequestErrorPrivate(NetworkRequestError::Type code, std::string &&msg, std::map< std::string, boost::any > &&extraInfo)
static zyppng::NetworkRequestError fromCurlMError(int nativeCode)
NetworkRequestErrorPrivate * clone() const
static zyppng::NetworkRequestError fromCurlError(NetworkRequest &req, int nativeCode, const std::string &nativeError)
static zyppng::NetworkRequestError customError(NetworkRequestError::Type t, std::string &&errorMsg="", std::map< std::string, boost::any > &&extraInfo={})
std::map< std::string, boost::any > _extraInfo
std::string _errorMessage
NetworkRequestError::Type _errorCode
The NetworkRequestError class Represents a error that occured in.
std::string toString() const
toString Returns a string representation of the error
const std::map< std::string, boost::any > & extraInfo() const
Type type() const
type Returns the type of the error
std::string nativeErrorString() const
bool isError() const
isError Will return true if this is a actual error
zypp::RWCOW_pointer< NetworkRequestErrorPrivate > d_ptr
const zypp::Pathname & targetFilePath() const
Returns the target filename path.
void * nativeHandle() const
TransferSettings & transferSettings()
const std::string & lastRedirectInfo() const
std::string numstring(char n, int w=0)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
constexpr std::string_view CurlNativeErrorDescKey
constexpr std::string_view CurlNativeErrorCodeDescKey
#define ZYPP_IMPL_PRIVATE(Class)