From f4746da4cab87b83a8f26a59fcf02717a0715e9a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 28 Sep 2017 12:01:58 -0400 Subject: [PATCH] webdav: Improve error message for failed request to include the request method and path. --- CHANGELOG | 7 +++++++ Remote/WebDAV.hs | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5bb80eebcb..8b16788a2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +git-annex (6.20170926) UNRELEASED; urgency=medium + + * webdav: Improve error message for failed request to include the request + method and path. + + -- Joey Hess Thu, 28 Sep 2017 12:01:39 -0400 + git-annex (6.20170925) unstable; urgency=medium * git-annex export: New command, can create and efficiently update diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs index 495b3f8fcc..6714dcbe40 100644 --- a/Remote/WebDAV.hs +++ b/Remote/WebDAV.hs @@ -16,6 +16,7 @@ import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.UTF8 as B8 import qualified Data.ByteString.Lazy.UTF8 as L8 import Network.HTTP.Client (HttpException(..), RequestBody) +import qualified Network.HTTP.Client as HTTP import Network.HTTP.Types import System.IO.Error import Control.Monad.Catch @@ -378,17 +379,20 @@ goDAV (DavHandle ctx user pass _) a = choke $ run $ prettifyExceptions $ do prettifyExceptions :: DAVT IO a -> DAVT IO a prettifyExceptions a = catchJust (matchStatusCodeException (const True)) a go where - go (HttpExceptionRequest _ (StatusCodeException response message)) = error $ unwords + go (HttpExceptionRequest req (StatusCodeException response message)) = giveup $ unwords [ "DAV failure:" , show (responseStatus response) , show (message) + , "HTTP request:" + , show (HTTP.method req) + , show (HTTP.path req) ] go e = throwM e #else prettifyExceptions :: DAVT IO a -> DAVT IO a prettifyExceptions a = catchJust (matchStatusCodeException (const True)) a go where - go (StatusCodeException status _ _) = error $ unwords + go (StatusCodeException status _ _) = giveup $ unwords [ "DAV failure:" , show (statusCode status) , show (statusMessage status)