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

QC: replace stop() with rlang::abort() throughout package #1976

Closed
lauramaxwell opened this issue Dec 5, 2024 · 6 comments · Fixed by #1994
Closed

QC: replace stop() with rlang::abort() throughout package #1976

lauramaxwell opened this issue Dec 5, 2024 · 6 comments · Fixed by #1994
Assignees
Milestone

Comments

@lauramaxwell
Copy link
Contributor

QC Details

use rlang::abort() instead of stop() for fatal errors so that it can provide more information, rather than just the message. See this for more information on the differences

Additional Comments

@jonthegeek
Copy link
Contributor

cli::cli_abort() wraps rlang::abort() but adds nice formatting. I'd definitely recommend going all the way there.

@lauramaxwell
Copy link
Contributor Author

yeah, i was going off of devin's comment, but sort of think it makes sense to use cli formatting in a log4r fatal log per zelos' work. happy to come up with a solution that makes the most sense here in the comments

@lauramaxwell lauramaxwell added this to the v2.2.1 milestone Dec 6, 2024
@zdz2101
Copy link
Collaborator

zdz2101 commented Dec 11, 2024

I believe I wrapped both "ERROR" and "FATAL" in logger as cli::cli_abort() because I couldn't quite figure out the difference between errors and fatal in our gsm package, I can certainly start drafting where to do the proper inserts

@zdz2101 zdz2101 self-assigned this Dec 11, 2024
@zdz2101
Copy link
Collaborator

zdz2101 commented Dec 11, 2024

How do we feel about the:

  • stopifnot() messages
  • stop_if_empty() is currently a wrapper for only 3 calls inside MakeBounds() ?

Should we create some sort of assert/stop wrapper along the lines of:

stop_if  <- function(condition, message) {
     if(condition) {
     LogMessage(level = "error", message = message)
    }
}

it would collapse these calls and use the log4r setup we have?
@jonthegeek @lauramaxwell @samussiah

@jonthegeek
Copy link
Contributor

stopifnot() is convenient, but it'd be nice for it to hook into logging & cli-style messaging. I definitely support implementing something like this! We could even include stop_if_not() as a convenience wrapper to make conversion easier:

stop_if_not <- function(condition, message) {
  stop_if(!condition, message)
}

@samussiah
Copy link
Contributor

How do we feel about the:

  • stopifnot() messages
  • stop_if_empty() is currently a wrapper for only 3 calls inside MakeBounds() ?

Should we create some sort of assert/stop wrapper along the lines of:

stop_if  <- function(condition, message) {
     if(condition) {
     LogMessage(level = "error", message = message)
    }
}

it would collapse these calls and use the log4r setup we have? @jonthegeek @lauramaxwell @samussiah

Love it.

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

Successfully merging a pull request may close this issue.

4 participants