ucb/source/ucp/webdav-curl/CurlSession.cxx   |   21 ++++++++++++++-------
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |   11 ++++++-----
 2 files changed, 20 insertions(+), 12 deletions(-)

New commits:
commit 3725d51647b318b680a003afc7cf20c02dc06ef8
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Jun 21 20:06:32 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Jun 24 17:37:19 2024 +0200

    ucb: webdav-curl: try to get the curl error message for more errors
    
    Change-Id: Iad39deeeef55498628616762b6b8dddc5a8f7475
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169345
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index 183f8ad6f96a..65f5f684b9fb 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -992,13 +992,16 @@ auto CurlProcessor::ProcessRequestImpl(
         switch (rc)
         {
             case CURLE_UNSUPPORTED_PROTOCOL:
-                throw DAVException(DAVException::DAV_UNSUPPORTED);
+                throw DAVException(DAVException::DAV_UNSUPPORTED, u""_ustr,
+                                   rtl::OStringToOUString(errorString, 
RTL_TEXTENCODING_UTF8));
             case CURLE_COULDNT_RESOLVE_PROXY:
-                throw DAVException(DAVException::DAV_HTTP_LOOKUP, 
rSession.m_Proxy);
+                throw DAVException(DAVException::DAV_HTTP_LOOKUP, 
rSession.m_Proxy,
+                                   rtl::OStringToOUString(errorString, 
RTL_TEXTENCODING_UTF8));
             case CURLE_COULDNT_RESOLVE_HOST:
                 throw DAVException(
                     DAVException::DAV_HTTP_LOOKUP,
-                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
+                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()),
+                    rtl::OStringToOUString(errorString, 
RTL_TEXTENCODING_UTF8));
             case CURLE_COULDNT_CONNECT:
             case CURLE_SSL_CONNECT_ERROR:
             case CURLE_SSL_CERTPROBLEM:
@@ -1020,7 +1023,8 @@ auto CurlProcessor::ProcessRequestImpl(
             case CURLE_AUTH_ERROR:
                 throw DAVException(
                     DAVException::DAV_HTTP_AUTH, // probably?
-                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
+                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()),
+                    rtl::OStringToOUString(errorString, 
RTL_TEXTENCODING_UTF8));
             case CURLE_WRITE_ERROR:
             case CURLE_READ_ERROR: // error returned from our callbacks
             case CURLE_OUT_OF_MEMORY:
@@ -1033,13 +1037,16 @@ auto CurlProcessor::ProcessRequestImpl(
             case CURLE_RECURSIVE_API_CALL:
                 throw DAVException(
                     DAVException::DAV_HTTP_FAILED,
-                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
+                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()),
+                    rtl::OStringToOUString(errorString, 
RTL_TEXTENCODING_UTF8));
             case CURLE_OPERATION_TIMEDOUT:
                 throw DAVException(
                     DAVException::DAV_HTTP_TIMEOUT,
-                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()));
+                    ConnectionEndPointString(rSession.m_URI.GetHost(), 
rSession.m_URI.GetPort()),
+                    rtl::OStringToOUString(errorString, 
RTL_TEXTENCODING_UTF8));
             default: // lots of generic errors
-                throw DAVException(DAVException::DAV_HTTP_ERROR, u""_ustr, 0);
+                throw DAVException(DAVException::DAV_HTTP_ERROR, u""_ustr,
+                                   rtl::OStringToOUString(errorString, 
RTL_TEXTENCODING_UTF8));
         }
     }
     // error handling part 2: HTTP status codes
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index e2533fee9bca..96c0a4f1de61 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3913,6 +3913,9 @@ Content::ResourceType Content::getResourceType(
                             break;
                         case USC_CONNECTION_TIMED_OUT:
                             e = DAVException::DAV_HTTP_TIMEOUT;
+                            throw DAVException(e,
+                                    ConnectionEndPointString(aHostName, nPort),
+                                    aDAVOptions.getHttpResponseStatusText());
                             break;
                         case USC_AUTH_FAILED:
                             e = DAVException::DAV_HTTP_AUTH;
@@ -4065,11 +4068,9 @@ void Content::getResourceOptions(
                     // cache the internal unofficial status code
 
                     aDAVOptions.setHttpResponseStatusCode(e.getError() == 
DAVException::DAV_HTTP_CONNECT ? USC_CONNECT_FAILED : USC_CONNECTION_TIMED_OUT);
-                    if (e.getError() == DAVException::DAV_HTTP_CONNECT)
-                    {   // ugly: this is not a HTTP status from the server but 
message
-                        // from libcurl but the string member is unused...
-                        aDAVOptions.setHttpResponseStatusText(e.getMessage());
-                    }
+                    // ugly: this is not a HTTP status from the server but 
message
+                    // from libcurl but the string member is unused...
+                    aDAVOptions.setHttpResponseStatusText(e.getMessage());
                     // used only internally, so the text doesn't really 
matter..
                     aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
                                                           
m_nOptsCacheLifeNotFound );

Reply via email to