Skip to content

Commit e709ea2

Browse files
committed
use Abort in errors
1 parent 964e46d commit e709ea2

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ importFrom(rlang,enquo)
9898
importFrom(rlang,enquos)
9999
importFrom(rlang,f_env)
100100
importFrom(rlang,f_rhs)
101+
importFrom(rlang,global_env)
101102
importFrom(rlang,is_environment)
102103
importFrom(rlang,is_formula)
103104
importFrom(rlang,is_function)

R/utils.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ assert_sufficient_f_args <- function(f, ..., n_mandatory_f_args = 2L) {
229229
#'
230230
#' @importFrom rlang check_dots_empty0 is_function new_function f_env
231231
#' is_environment missing_arg f_rhs is_string is_formula caller_arg
232-
#' caller_env
232+
#' caller_env global_env
233233
as_slide_computation <- function(x,
234234
env = global_env(),
235235
...,
@@ -243,18 +243,19 @@ as_slide_computation <- function(x,
243243

244244
if (is_formula(x)) {
245245
if (length(x) > 2) {
246-
rlang:::abort_coercion(
247-
x,
248-
x_type = "a two-sided formula",
249-
to_type = "a slide computation",
250-
arg = arg,
251-
call = call
252-
)
246+
Abort(sprintf("%s must be a one-sided formula", arg),
247+
class = "epiprocess__as_slide_computation__formula_is_twosided",
248+
epiprocess__x = x,
249+
call = call)
253250
}
254251

255252
env <- f_env(x)
256253
if (!is_environment(env)) {
257-
abort("Formula must carry an environment.", arg = arg, call = call)
254+
Abort("Formula must carry an environment.",
255+
class = "epiprocess__as_slide_computation__formula_has_no_env",
256+
epiprocess__x = x,
257+
epiprocess__x_env = env,
258+
arg = arg, call = call)
258259
}
259260

260261
args <- list(
@@ -271,7 +272,12 @@ as_slide_computation <- function(x,
271272
return(get(x, envir = env, mode = "function"))
272273
}
273274

274-
rlang:::abort_coercion(x, "a slide computation", arg = arg, call = call)
275+
Abort(sprintf("Can't convert a %s to a slide computation", class(x)),
276+
class = "epiprocess__as_slide_computation__cant_convert_catchall",
277+
epiprocess__x = x,
278+
epiprocess__x_class = class(x),
279+
arg = arg,
280+
call = call)
275281
}
276282

277283
##########

0 commit comments

Comments
 (0)