From 8ec3e12a66dcf00228f14b4774b59f33755f4c0e Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:13:00 +0200 Subject: [PATCH 1/2] fix: return correct error message when workspace doesn't exist --- R/utils.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index 5c7cb02..0ab98ce 100644 --- a/R/utils.R +++ b/R/utils.R @@ -53,8 +53,8 @@ } else if (response$status_code == 401) { stop("Unauthorized", call. = FALSE) } else if (response$status_code == 500) { - json_content <- httr::content(response) - stop(paste0("Internal server error: ", json_content$message), call. = FALSE) + json_content <- httr::content(response, "text") + stop(paste0("Internal server error: ", json_content), call. = FALSE) } } From 1675a1d8e08d16f40b5518ce944628ebf9b52554 Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:56:58 +0200 Subject: [PATCH 2/2] tests: updated with fix --- tests/testthat/test-utils.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index afdeb75..f4b9a79 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -65,11 +65,11 @@ test_that(".handle_request_error handles 400", { test_that(".handle_request_error handles 500", { response <- list(status_code = 500) - httr_content <- mock(list(message = "Error")) + httr_content <- mock(message = "Something went wrong while reading/writing in the storage") with_mock( expect_error( .handle_request_error(response), - "Internal server error: Error" + "Internal server error: Something went wrong while reading/writing in the storage", ), "httr::content" = httr_content )