-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
address #6: allow custom messages #11
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
.lintr |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
# default handling | ||
internal_error <- function(..., call) stop(...) | ||
internal_warn <- function(..., call) warning(...) | ||
|
||
.onLoad <- function(libname, pkgname) { | ||
if (requireNamespace("cli", quietly = TRUE)) { | ||
utils::assignInMyNamespace( | ||
"internal_error", | ||
function( | ||
..., call = parent.frame() | ||
) { | ||
cli::cli_abort(message = c(...), call = call) | ||
} | ||
) | ||
utils::assignInMyNamespace( | ||
"internal_warn", | ||
function( | ||
..., call = parent.frame() | ||
) { | ||
cli::cli_warn(message = c(...), call = call) | ||
} | ||
) | ||
} | ||
} | ||
|
||
.onAttach <- function(libname, pkgname) { | ||
if (requireNamespace("cli", quietly = TRUE)) { | ||
packageStartupMessage("coerceDT: using `cli` messaging.") | ||
} else { | ||
packageStartupMessage( | ||
paste(c( | ||
"coerceDT: using `base` messaging.", | ||
"To use `cli` messages, install `cli` and restart your session." | ||
), collapse = "\n\t") | ||
) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intended that no args are passed to
internall_error()
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - it's passing the functional handler.