Skip to content

Commit

Permalink
remove error; dont interrupt cond evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
yjunechoe committed Oct 10, 2024
1 parent 89825b5 commit 7009ca6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions R/sublayer-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,16 @@ layer_is <- function(expr) {
}
by_layer_idx <- which(sapply(sys.calls(), rlang::is_call, "by_layer"))[1]
if (is.na(by_layer_idx)) {
# Don't trigger if not downstream of `by_layer()`
return(FALSE)
}
by_layer_env <- rlang::env_clone(sys.frames()[[by_layer_idx]])

if (is.numeric(x)) {
n_layers <- length(by_layer_env$layers)
if (x > n_layers) {
cli::cli_abort(
"[ggtrace] Plot has {n_layers} layer{?s} - {x} is invalid.",
call = rlang::call2("layer_is", x)
)
# Will never trigger if targeting layer outside of number of layer
return(FALSE)
}
x <- rlang::call2("==", quote(i), as.integer(x))
}
Expand Down

0 comments on commit 7009ca6

Please sign in to comment.