Skip to content

Commit 691fd74

Browse files
committed
Simplify oe_stop
1 parent eead8bd commit 691fd74

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

R/utils.R

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,15 @@ extract_dots_names_safely <- function(...) {
148148
)
149149
}
150150

151-
# See https://adv-r.hadley.nz/conditions.html#signalling. Code taken from that
152-
# book (and I think that's possible since the code is released with MIT
153-
# license). The main benefit of this approach is that I can test the class of
154-
# the error instead of the message.
151+
# See https://adv-r.hadley.nz/conditions.html#signalling and ?condition. The
152+
# main benefit of this approach is that I can test the class of the error
153+
# instead of the message.
155154
oe_stop <- function(.subclass, message, call = NULL, ...) {
156-
err <- structure(
157-
list(
158-
message = message,
159-
call = call,
160-
...
161-
),
162-
class = c(.subclass, "error", "condition")
155+
err <- errorCondition(
156+
message = message,
157+
...,
158+
class = .subclass,
159+
call = call
163160
)
164161
stop(err)
165162
}

0 commit comments

Comments
 (0)