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

More informative error message with inline markup #687

Open
olivroy opened this issue Apr 18, 2024 · 1 comment
Open

More informative error message with inline markup #687

olivroy opened this issue Apr 18, 2024 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@olivroy
Copy link
Contributor

olivroy commented Apr 18, 2024

It would be great if errors could be rethrown by cli?

If I have this code lost somewhere, it is a bit difficult to find the location.

y <- "{cli}"
cli::format_inline(y)
#> Error in paste0(before, x, after) : 
#>  cannot coerce type 'closure' to vector of type 'character
 cli::format_inline("{.file {x")
#> Error in glue(str, .envir = .envir, .transformer = transformer, .cli = TRUE,  : 
#>  Expecting '}'

It is a bit difficult to know where this error is occuring, especially as these are internal. They should not reach the end user, but while iterating, it can be difficult to find the source of the error.

Maybe cli could check in advance if parenthesis are well balanced?

@gaborcsardi
Copy link
Member

Maybe cli could check in advance if parenthesis are well balanced?

That is very difficult, and basically means evaluating the whole thing.

cli calls as.character() and that fails for closures. Maybe we can catch that error, and give a better error message, but what would that error message look like?

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants