Skip to content

Commit

Permalink
only throw "Unable to locate" error when pal is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Oct 25, 2024
1 parent 063ad6c commit f2f388b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/init-addin.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@
.init_addin <- function() {
# suppress "Listening on..." message and rethrow errors with new context
try_fetch(
suppressMessages(pal_fn <- .pal_app()),
suppressMessages(pal_fn_name <- .pal_app()),
error = function(cnd) {cli::cli_abort(conditionMessage(cnd), call = NULL)}
)

if (is.null(pal_fn) || identical(pal_fn, ".pal_rs_")) {
if (is.null(pal_fn_name) || identical(pal_fn_name, ".pal_rs_")) {
return(invisible())
}

# call the binding associated with the chosen pal
try_fetch(
do.call(env_get(pal_env(), pal_fn), args = list()),
pal_fn <- env_get(pal_env(), pal_fn_name),
error = function(e) {
cli::cli_abort("Unable to locate the requested pal.")
}
)

do.call(pal_fn, args = list())

invisible()
}

Expand Down

0 comments on commit f2f388b

Please sign in to comment.