Skip to content
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

Global calling handlers #1

Open
HenrikBengtsson opened this issue Jun 11, 2022 · 1 comment
Open

Global calling handlers #1

HenrikBengtsson opened this issue Jun 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@HenrikBengtsson
Copy link

Funny.

FYI, in R (>= 4.0.0), you can use globalCallingHandlers() to "subscribe" to conditions without having to use withCallingHandlers(). In other words, you can capture and generate your output everywhere.

Gist,

globalCallingHandlers(warning = function(w) {
  message("Woo, careful there: ", conditionMessage(w))
})

and

> as.integer("a")
Woo, careful there: NAs introduced by coercion
[1] NA
Warning message:
NAs introduced by coercion
@gdagstn
Copy link
Owner

gdagstn commented Jun 12, 2022

Thank you @HenrikBengtsson, I did not know that!

I don't know if wrapping all messages would be considered too intrusive, seeing how much real estate the alamak messages take up on screen. But the point of this package is not to be taken seriously/used daily...

I will definitely give your suggestion a try and maybe let the user turn these warnings on or off with a call.

@gdagstn gdagstn added the enhancement New feature or request label Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants