From c673eb430dd31b126b420d0699a3476d1edc42e0 Mon Sep 17 00:00:00 2001 From: wkmor1 Date: Fri, 9 Feb 2024 12:53:34 +0200 Subject: [PATCH] Give more informative error when API key set Error message from API is now passed to user when they request a API key for an email that has already been assigned a key. --- R/finbif_request_token.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/finbif_request_token.R b/R/finbif_request_token.R index 541555c3..62fb749d 100644 --- a/R/finbif_request_token.R +++ b/R/finbif_request_token.R @@ -55,7 +55,7 @@ finbif_request_token <- function(email, quiet = FALSE) { pause_cap = getOption("finbif_retry_pause_cap"), pause_min = getOption("finbif_retry_pause_min"), quiet = quiet, - terminate_on = 404L + terminate_on = c(404L, 422L) ) parsed <- httr::content(resp) @@ -64,8 +64,8 @@ finbif_request_token <- function(email, quiet = FALSE) { msg <- sprintf( "API request failed [%s]\n%s", - resp[["status_code"]], - parsed[["message"]] + parsed[[c("error", "statusCode")]], + parsed[[c("error", "message")]] ) stop(msg, call. = FALSE)