-
Notifications
You must be signed in to change notification settings - Fork 14
#187: stop() -> rlang::abort() #192
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
base: main
Are you sure you want to change the base?
Changes from all commits
6a34239
b8c60a5
2517f58
b9465ef
ce29f4b
2366ff5
ff3b46b
fd70417
fd3d04c
8728097
a1726dd
cd65a0a
8c232d7
4663040
65659e9
c59a081
6351072
10180a3
e0d5523
08926c8
7bd4323
c54db3f
c52f0e9
ce83bf9
d68c98b
c34866c
0532920
3013504
8809e87
735c347
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,5 +64,6 @@ find_file <- function(file_path) { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| stop("Couldn't find the file ", file_path, " in any of the mock directories.") | ||||||||
| error_msg <- glue::glue("Couldn't find the file {file_path} in any of the mock directories.") | ||||||||
| rlang::abort(error_msg) | ||||||||
|
Comment on lines
+67
to
+68
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this is still under the 100 character lintr line limit, but would be good to confirm |
||||||||
| } | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,8 @@ | |||||||
| #' } | ||||||||
| use_dittodb <- function(path = ".") { | ||||||||
| if (!("DESCRIPTION" %in% dir(path))) { | ||||||||
| stop(path, " is not an R package directory", call. = FALSE) | ||||||||
| error_msg <- glue::glue("{path} is not an R package directory.") | ||||||||
| rlang::abort(error_msg) | ||||||||
|
Comment on lines
+34
to
+35
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Slightly simpler, what do you think? |
||||||||
| } | ||||||||
| add_dittodb_to_desc(file.path(path, "DESCRIPTION")) | ||||||||
| # TODO: could allow helper.r too | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,7 +69,8 @@ get_dbname <- function(dots, drv = NULL) { | |||||||
| path <- "ephemeral_sqlite" | ||||||||
| } else { | ||||||||
| # if there is no name, or it's empty | ||||||||
| stop("There was no dbname, so I don't know where to look for mocks.") | ||||||||
| error_msg <- "There was no dbname, so I don't know where to look for mocks." | ||||||||
| rlang::abort(error_msg) | ||||||||
|
Comment on lines
+72
to
+73
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This should still be under the 100 character lintr limit, and nice to not have the extra line IMO |
||||||||
| } | ||||||||
| return(db_path_sanitize(path)) | ||||||||
| } | ||||||||
|
|
||||||||
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.
What does this look like when it occurs?
I know there are small differences in how newlines are handled (and it might even depend on if
cliis installed or not 🙈 ) Would you mind trying to trigger it with and without CLI in your env to see what it looks like and paste that here?Uh oh!
There was an error while loading. Please reload this page.
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.
Reprex:
Terminal:
Question, what do you mean by without CLI? I removed the {cli} package and ran the
rlang::abortand it printed the same. I think I am confused :)My R session
Uh oh!
There was an error while loading. Please reload this page.
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.
Hmmm that's odd. I just tried it locally (thanks for the reprex, that made it super easy!), and the content / spacing is the same, but I do see a (tiny) difference without the cli package:
with cli

without cli

The difference is very subtle here (just the coloring), but that's what I wanted to confirm. I looked at the docs for
rlang::abortand saw that it will use cli to format the messages (seeuse_cli_formatunder arguments), and when I clicked through to the page on formatting there was some discussion about changes in format and whitespace — though those might be limited to only when usingcli::cli_abortinstead of `rlang::abort formatted with cli (I will be honest, I couldn't totally tell from this page when I read it!)There is another thing on that page that's a little worrying about user input, but that also looks exclusive to
cli::cli_abortand notrlang::abortwhich has been formatted with cli:So I think this is good — though what do you think about:
It's mostly a personal preference, but I prefer explicitly escaped new lines as opposed to having it in the quote and overflowing. I also took out the
glue::since it's already imported to dittodbThere 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.
This also could be incorporated into the
abortcall, though this is starting to get big enough a separate variable is ok. What do you think?