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
This commit is contained in:
Michael Stahl 2024-06-20 15:13:17 +02:00
parent eedbe966bb
commit b02eb998c1
7 changed files with 35 additions and 4 deletions

View file

@ -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: */

View file

@ -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:\n$(ARG2)") , ERRCODE_INET_CONNECT_MSG },
{ NC_("RID_ERRHDL", "Error reading data from the Internet.\nServer error message: $(ARG1).") , ERRCODE_INET_READ },
{ NC_("RID_ERRHDL", "Error transferring data to the Internet.\nServer error message: $(ARG1).") , ERRCODE_INET_WRITE },
{ NC_("RID_ERRHDL", "General Internet error has occurred.") , ERRCODE_INET_GENERAL },

View file

@ -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:

View file

@ -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; }
};

View file

@ -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 );

View file

@ -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 += "\n" + aMessage2;
}
}
}
aMessage = replaceMessageWithArguments( aMessage, rArguments );

View file

@ -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)
{