From a79eed9f2217cf2ba731fc5f5024aa69c6898107 Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Fri, 3 Feb 2023 11:49:50 +0100 Subject: [PATCH] Include requestURI in error text --- dicom/client_test.go | 2 +- internal/check_response.go | 6 +++++- internal/version.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dicom/client_test.go b/dicom/client_test.go index 20764fd7..a12a1049 100644 --- a/dicom/client_test.go +++ b/dicom/client_test.go @@ -250,5 +250,5 @@ func TestErrorResponse(t *testing.T) { return } assert.Equal(t, http.StatusConflict, resp.StatusCode()) - assert.Equal(t, err.Error(), `POST : StatusCode 409, Body: {"error":"something unexpected happened"}`) + assert.Equal(t, err.Error(), `POST /store/dicom/config/dicom/production/remoteNodes: StatusCode 409, Body: {"error":"something unexpected happened"}`) } diff --git a/internal/check_response.go b/internal/check_response.go index 0d53a70f..96c72586 100644 --- a/internal/check_response.go +++ b/internal/check_response.go @@ -22,5 +22,9 @@ func CheckResponse(r *http.Response) error { data = []byte("empty") } r.Body = io.NopCloser(bytes.NewBuffer(data)) // Preserve body - return fmt.Errorf("%s %s: StatusCode %d, Body: %s", r.Request.Method, r.Request.RequestURI, r.StatusCode, string(data)) + requestURI := "" + if r.Request.URL != nil { + requestURI = r.Request.URL.RequestURI() + } + return fmt.Errorf("%s %s: StatusCode %d, Body: %s", r.Request.Method, requestURI, r.StatusCode, string(data)) } diff --git a/internal/version.go b/internal/version.go index acf45c6c..23ada203 100644 --- a/internal/version.go +++ b/internal/version.go @@ -1,5 +1,5 @@ package internal const ( - LibraryVersion = "0.77.7" + LibraryVersion = "0.77.8" )