include/comphelper/errcode.hxx               |    1 +
 svtools/inc/errtxt.hrc                       |    1 +
 ucb/source/ucp/webdav-curl/CurlSession.cxx   |    7 ++++---
 ucb/source/ucp/webdav-curl/DAVException.hxx  |    9 +++++++++
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |   10 +++++++++-
 uui/source/iahndl-errorhandler.cxx           |   10 ++++++++++
 uui/source/iahndl.cxx                        |    1 +
 7 files changed, 35 insertions(+), 4 deletions(-)

New commits:
commit b02eb998c1f05ccb2c1e82f4ba24779398bce72e
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Jun 20 15:13:17 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Jun 21 11:35:51 2024 +0200

    uui,ucb: webdav-curl: display curl error message on connection failure
    
    Show this in the dialog, which requires extending DAVException to store
    2 strings for this case.
    
    Store it in the Exception::Message member of
    InteractiveNetworkConnectException, which appears to be unused.
    
    Add another UI string ERRCODE_INET_CONNECT_MSG so that the text can be
    shown optionally in the dialog.
    
    Change-Id: Iaf139d77051e7480113eb4df82ef40eb498f329e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169278
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins

diff --git a/include/comphelper/errcode.hxx b/include/comphelper/errcode.hxx
index 31c4457db4b5..547be70a13dd 100644
--- a/include/comphelper/errcode.hxx
+++ b/include/comphelper/errcode.hxx
@@ -366,5 +366,6 @@ enum class ErrCodeClass {
 #define ERRCODE_INET_WRITE               ErrCode(ErrCodeArea::Inet, 
ErrCodeClass::Write, 4)
 #define ERRCODE_INET_GENERAL             ErrCode(ErrCodeArea::Inet, 
ErrCodeClass::Write, 5)
 #define ERRCODE_INET_OFFLINE             ErrCode(ErrCodeArea::Inet, 
ErrCodeClass::Read,  6)
+#define ERRCODE_INET_CONNECT_MSG         ErrCode(ErrCodeArea::Inet, 
ErrCodeClass::Read,  7)
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/inc/errtxt.hrc b/svtools/inc/errtxt.hrc
index a70c0b284704..f98f12e916ea 100644
--- a/svtools/inc/errtxt.hrc
+++ b/svtools/inc/errtxt.hrc
@@ -108,6 +108,7 @@ const ErrMsgCode RID_ERRHDL[] =
     { NC_("RID_ERRHDL", "General OLE Error.") , ERRCODE_SFX_OLEGENERAL },
     { NC_("RID_ERRHDL", "The host name $(ARG1) could not be resolved.") , 
ERRCODE_INET_NAME_RESOLVE },
     { NC_("RID_ERRHDL", "Could not establish Internet connection to $(ARG1).") 
, ERRCODE_INET_CONNECT },
+    { NC_("RID_ERRHDL", "Client error message:
$(ARG2)") , ERRCODE_INET_CONNECT_MSG },
     { NC_("RID_ERRHDL", "Error reading data from the Internet.
Server error message: $(ARG1).") , ERRCODE_INET_READ },
     { NC_("RID_ERRHDL", "Error transferring data to the Internet.
Server error message: $(ARG1).") , ERRCODE_INET_WRITE },
     { NC_("RID_ERRHDL", "General Internet error has occurred.") , 
ERRCODE_INET_GENERAL },
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx 
b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index ebc26784186e..183f8ad6f96a 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -987,8 +987,8 @@ auto CurlProcessor::ProcessRequestImpl(
     if (rc != CURLE_OK)
     {
         // TODO: is there any value in extracting CURLINFO_OS_ERRNO
-        SAL_WARN("ucb.ucp.webdav.curl",
-                 "curl_easy_perform failed: " << GetErrorString(rc, 
rSession.m_ErrorBuffer));
+        auto const errorString(GetErrorString(rc, rSession.m_ErrorBuffer));
+        SAL_WARN("ucb.ucp.webdav.curl", "curl_easy_perform failed: " << 
errorString);
         switch (rc)
         {
             case CURLE_UNSUPPORTED_PROTOCOL:
@@ -1013,7 +1013,8 @@ auto CurlProcessor::ProcessRequestImpl(
 #endif
                 throw DAVException(
                     DAVException::DAV_HTTP_CONNECT,
-                    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_REMOTE_ACCESS_DENIED:
             case CURLE_LOGIN_DENIED:
             case CURLE_AUTH_ERROR:
diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx 
b/ucb/source/ucp/webdav-curl/DAVException.hxx
index bd3053305901..adfa29317789 100644
--- a/ucb/source/ucp/webdav-curl/DAVException.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVException.hxx
@@ -145,6 +145,7 @@ class DAVException : public std::exception
     private:
         ExceptionCode   mExceptionCode;
         OUString   mData;
+        OUString   mMessage;
         sal_uInt16      mStatusCode;
 
     public:
@@ -159,6 +160,13 @@ class DAVException : public std::exception
              , mData(std::move( aData ))
              , mStatusCode( SC_NONE )
          {};
+         DAVException( ExceptionCode inExceptionCode,
+                       OUString aData, OUString message)
+             : mExceptionCode( inExceptionCode )
+             , mData(std::move( aData ))
+             , mMessage(std::move(message))
+             , mStatusCode( SC_NONE )
+         {};
          DAVException( ExceptionCode inExceptionCode,
                        OUString aData,
                        sal_uInt16 nStatusCode )
@@ -169,6 +177,7 @@ class DAVException : public std::exception
 
     const ExceptionCode & getError() const { return mExceptionCode; }
     const OUString & getData() const  { return mData; }
+    const OUString & getMessage() const { return mMessage; }
     sal_uInt16 getStatus() const { return mStatusCode; }
 };
 
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index c33e4cb24bcc..e2533fee9bca 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3606,7 +3606,7 @@ uno::Any Content::MapDAVException( const DAVException & 
e, bool bWrite )
     case DAVException::DAV_HTTP_CONNECT:
         aException <<=
             ucb::InteractiveNetworkConnectException(
-                OUString(),
+                e.getMessage(),
                 getXWeak(),
                 task::InteractionClassification_ERROR,
                 e.getData() );
@@ -3907,6 +3907,9 @@ Content::ResourceType Content::getResourceType(
                     {
                         case USC_CONNECT_FAILED:
                             e = DAVException::DAV_HTTP_CONNECT;
+                            throw DAVException(e,
+                                    ConnectionEndPointString(aHostName, nPort),
+                                    aDAVOptions.getHttpResponseStatusText());
                             break;
                         case USC_CONNECTION_TIMED_OUT:
                             e = DAVException::DAV_HTTP_TIMEOUT;
@@ -4062,6 +4065,11 @@ 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());
+                    }
                     // used only internally, so the text doesn't really 
matter..
                     aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
                                                           
m_nOptsCacheLifeNotFound );
diff --git a/uui/source/iahndl-errorhandler.cxx 
b/uui/source/iahndl-errorhandler.cxx
index e4be8a713911..c6b17d627eaa 100644
--- a/uui/source/iahndl-errorhandler.cxx
+++ b/uui/source/iahndl-errorhandler.cxx
@@ -160,6 +160,16 @@ UUIInteractionHelper::handleErrorHandlerRequest(
         ErrorResource aErrorResource(aId[eSource], aResLocale);
         if (!aErrorResource.getString(nErrorCode, aMessage))
             return;
+        if (nErrorCode == ERRCODE_INET_CONNECT)
+        {
+            OUString aMessage2;
+            aErrorResource.getString(ERRCODE_INET_CONNECT_MSG, aMessage2);
+            if (!aMessage2.isEmpty() && !rArguments[1].isEmpty())
+            {
+                aMessage2 = replaceMessageWithArguments(aMessage2, rArguments);
+                aMessage += "
" + aMessage2;
+            }
+        }
     }
 
     aMessage = replaceMessageWithArguments( aMessage, rArguments );
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 298754138990..de8809c404fc 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -498,6 +498,7 @@ UUIInteractionHelper::handleRequest_impl(
             {
                 nErrorCode = ERRCODE_INET_CONNECT;
                 aArguments.push_back(aConnectException.Server);
+                aArguments.push_back(aConnectException.Message);
             }
             else if (aAnyRequest >>= aReadException)
             {

Reply via email to