Skip to content

Commit

Permalink
catch bad token sooner
Browse files Browse the repository at this point in the history
ref #415
  • Loading branch information
wibeasley committed Sep 5, 2022
1 parent 9383f55 commit 4c82e12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions R/redcap-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ redcap_read <- function(
config_options = config_options
)

# if (!metadata$success) {
# error_message <- sprintf(
# "The REDCapR record export operation was not successful. The error message was:\n%s",
# metadata$raw_text
# )
# stop(error_message)
# }
if (!metadata$success) {
error_message <- sprintf(
"The REDCapR record export operation was not successful. The error message was:\n%s",
metadata$raw_text
)
stop(error_message)
}

initial_call <- REDCapR::redcap_read_oneshot(
redcap_uri = redcap_uri,
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-read-batch-simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ test_that("date-range", {
test_that("error-bad-token", {
testthat::skip_on_cran()

expected_outcome_message <- "The REDCapR read/export operation was not successful\\."
expect_message(
expected_outcome_message <- "The REDCapR record export operation was not successful\\."
expect_error(
regexp = expected_outcome_message,
redcap_read(
redcap_uri = credential$redcap_uri,
Expand Down

0 comments on commit 4c82e12

Please sign in to comment.