You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few functions that call stop() to signal invalid inputs or other user errors. We should use cli_abort() for these. It allows you to give detail on the types of arguments and what was expected, in a much friendlier way than just pasting together a message in stop().
if (!inherits(population, "population")) {
cli_abort(c("{.arg population} argument must be a population defined with {.fn population}",
"i"="Received {.type {population}} instead"))
}
cli_abort(
c("Diagnostic function {.arg fn} must return a data frame or tibble",
"x"="{.arg fn} returned a result of class {.cls {class(x)}}"),
class="regressinator_diagnostic_class",
call= caller_env()
)
These get pretty-printed with colored formatting, and the markup like {.cls} produces nice formatting. For instance, here's what you get from the second example:
Error in `sampling_distribution()`:
! diagnostic function `fn` must return a data frame or tibble
✖ `fn` returned a result of class <character>
Run `rlang::last_trace()` to see where the error occurred.
The text was updated successfully, but these errors were encountered:
There are a few functions that call
stop()
to signal invalid inputs or other user errors. We should usecli_abort()
for these. It allows you to give detail on the types of arguments and what was expected, in a much friendlier way than just pasting together a message instop()
.Here are a couple examples from a package of mine:
These get pretty-printed with colored formatting, and the markup like
{.cls}
produces nice formatting. For instance, here's what you get from the second example:The text was updated successfully, but these errors were encountered: