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

Code Smell: Error Handling Eclipse | Credibly Curious #75

Open
utterances-bot opened this issue Dec 22, 2023 · 8 comments
Open

Code Smell: Error Handling Eclipse | Credibly Curious #75

utterances-bot opened this issue Dec 22, 2023 · 8 comments

Comments

@utterances-bot
Copy link

Code Smell: Error Handling Eclipse | Credibly Curious

https://www.njtierney.com/post/2023/12/06/long-errors-smell/

Copy link

Wonderful post, Nick! Thanks for such a great write up!

Copy link

This was very informative & practical! Thank you.

Copy link

lovely post! Some of this was covered in the Posit::conf dev masterclass, and this was a great reminder and expansion of that!

@njtierney
Copy link
Collaborator

Thanks everyone! So very stoked that you liked the post 😄

Copy link

Thanks, Nick. This was really insightful. I think the rlang package is the best thing we never knew we needed as R package developers. On another note, I am currently struggling with including the name of the caller function in warning messages thrown with cli::cli_warn(). Do you have any advise on that? I am tempted to remove them where they're unnecessary and replace them with errors where they are indeed fatal. I saw some advise in the Advanced R book about the awkward nature of R warnings and I'm beginning to think they're not the best way to signal non-fatal issues, especially when you have to catch and manipulate them.

@njtierney
Copy link
Collaborator

Thanks for the kind words, @jamesmbaazam !

On another note, I am currently struggling with including the name of the caller function in warning messages thrown with cli::cli_warn()

Have you specified the argument as call = rlang::caller_env()? This way you could control how it is presented to the user, I believe?

@jamesmbaazam
Copy link

Yes, I tried that but I think cli::cli_warning() doesn't actually expect a call argument?

@njtierney
Copy link
Collaborator

Ah yes I was sort of expecting ... was pass eventually to call, since cli::cli_warning() doesn't have call listed as an argument but it instead gets passed to rlang::warn() via ... https://cli.r-lib.org/reference/cli_abort.html, and ... gets passed to rlang::abort()/rlang::warn()/rlang::inform(). But only rlang::abort() has a call arg.

r-lib/rlang#1496 seems to indicate that rlang::warn() should work?

I'll try and take a look at this when I've got some time, let me know if you have any luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants