Skip to content

Commit

Permalink
Merge pull request #88 from molgenis/fix/workspace-message
Browse files Browse the repository at this point in the history
fix: return correct error message when workspace doesn't exist
  • Loading branch information
timcadman authored Jul 25, 2024
2 parents e311946 + 1675a1d commit d693036
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit d693036

Please sign in to comment.