Skip to content

Commit

Permalink
Add 403 error message and use switch
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-hannah committed Mar 12, 2024
1 parent d9b4e4e commit 8c100e6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions R/objectiveR.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ objectiveR <- function(endpoint,
#' @return A character vector to include in error message.

error <- function(response) {
code <- httr2::resp_status(response)
if(code == 401) {
"Authorisation failed. Check username / password / token."
} else {
NULL
}

switch(
as.character(httr2::resp_status(response)),
"401" = "Authorisation failed. Check username / password / token.",
"403" = paste("Operation not permitted.")
)

}

0 comments on commit 8c100e6

Please sign in to comment.