This is an automated email from the ASF dual-hosted git repository.

ardovm pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 5f005af5090fe5fc933b857d234b9efe666f8f21
Author: Arrigo Marchiori <ard...@yahoo.it>
AuthorDate: Sun May 22 14:34:04 2022 +0200

    Decode Curl errors
    
    (cherry picked from commit b9e06544f399447a1a5df77229f012135bc131a9)
---
 main/ucb/source/ucp/webdav/CurlSession.cxx | 37 +++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/main/ucb/source/ucp/webdav/CurlSession.cxx 
b/main/ucb/source/ucp/webdav/CurlSession.cxx
index 5ca143273e..721f1aa4cb 100644
--- a/main/ucb/source/ucp/webdav/CurlSession.cxx
+++ b/main/ucb/source/ucp/webdav/CurlSession.cxx
@@ -770,9 +770,40 @@ void CurlSession::processResponse( CurlRequest 
&curlRequest, CURLcode curlCode )
     if ( curlCode != 0 )
     {
         m_aLogger.log( LogLevel::WARNING, "Curl request failed with CURLcode 
$1$", (sal_Int64)curlCode );
-        throw DAVException( DAVException::DAV_HTTP_LOOKUP,
-                            CurlUri::makeConnectionEndPointString( 
getHostName(),
-                                                                   getPort() ) 
);
+        DAVException::ExceptionCode exCode = DAVException::DAV_HTTP_ERROR;
+        rtl::OUString exData;
+        switch (curlCode) {
+        case CURLE_COULDNT_RESOLVE_HOST:
+            exCode = DAVException::DAV_HTTP_LOOKUP;
+            exData = CurlUri::makeConnectionEndPointString( getHostName(),
+                                                            getPort() );
+            break;
+        case CURLE_COULDNT_CONNECT:
+            exCode = DAVException::DAV_HTTP_CONNECT;
+            exData = CurlUri::makeConnectionEndPointString( getHostName(),
+                                                            getPort() );
+            break;
+        case CURLE_OPERATION_TIMEDOUT:
+            exCode = DAVException::DAV_HTTP_TIMEOUT;
+            exData = CurlUri::makeConnectionEndPointString( getHostName(),
+                                                            getPort() );
+            break;
+        case CURLE_LOGIN_DENIED:
+        case CURLE_AUTH_ERROR:
+            exCode = DAVException::DAV_HTTP_AUTH;
+            exData = CurlUri::makeConnectionEndPointString( getHostName(),
+                                                            getPort() );
+            break;
+        default:
+            {
+                const char *s = curl_easy_strerror(curlCode);
+                exCode = DAVException::DAV_HTTP_ERROR;
+                exData = ::rtl::OUString(s, strlen(s),
+                                         RTL_TEXTENCODING_UTF8);
+                break;
+            }
+        }
+        throw DAVException( exCode, exData );
     }
     
     rtl::OUString reasonPhrase = rtl::OStringToOUString( 
curlRequest.getReasonPhrase(), RTL_TEXTENCODING_UTF8 );

Reply via email to