summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-06-20 15:13:17 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2024-06-21 11:35:51 +0200
commitb02eb998c1f05ccb2c1e82f4ba24779398bce72e (patch)
tree41d3d3f239cb95f6c2d24c22b59a51a5819be17f /ucb
parenteedbe966bba1c070041b3a3ff836b4ef28e5bdaa (diff)
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.stahl@allotropia.de> Tested-by: Jenkins
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.cxx7
-rw-r--r--ucb/source/ucp/webdav-curl/DAVException.hxx9
-rw-r--r--ucb/source/ucp/webdav-curl/webdavcontent.cxx10
3 files changed, 22 insertions, 4 deletions
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:
@@ -160,6 +161,13 @@ class DAVException : public std::exception
, 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 )
: mExceptionCode( inExceptionCode )
@@ -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 );