Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve API error messages #70

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ For more information, please visit the [package website](https://laminr.lamin.ai

* Improve checking for suggested packages and provide installation instructions if missing (PR #56)

* Add the status code to API error messages (PR #70)

## TESTING

* Add a simple unit test which queries laminlabs/lamindata (PR #27).

* Added unit test for the InstanceAPI class (PR #30).

* Add a regular expression to the API test for missing records (PR #70)

## DOCUMENTATION

* Update `README` with new set up instructions and simplify (PR #14).
Expand Down
2 changes: 1 addition & 1 deletion R/InstanceAPI.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ InstanceAPI <- R6::R6Class( # nolint object_name_linter
detail <- content
}
cli_abort(c(
"Failed to {request_type} from instance",
"Failed to {request_type} from instance with status code {response$status_code}",
"i" = "Details: {detail}"
))
}
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-instance_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ test_that("get_record fails gracefully", {

api <- InstanceAPI$new(instance_settings)

# nolint start: commented_code
# TODO: improve error messages for these cases
expect_error(
api$get_record("core", "artifact", "foobar") # ,
# regexp = "Error getting record: list index out of range"
api$get_record("core", "artifact", "foobar"),
regexp = "404: Record not found"
)

# nolint start: commented_code
# TODO: improve error messages for these cases
expect_error(
api$get_record("core", "artifact", "mePviem4DGM4SFzvLXf3", select = "foo"),
# regexp = "Error getting record: invalid select field: foo"
Expand Down
Loading