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

Feature: option to choose between capture "parsing error" or "console error" #101

Closed
barboulotte opened this issue Mar 21, 2021 · 1 comment

Comments

@barboulotte
Copy link

Related question on SO: https://stackoverflow.com/questions/66603676/capture-error-messages-as-character-string-in-r/66660202

For pedagogical purposes, it would be usefull to capture "console error" rather than "parser error".

2 2
#> Error: unexpected numeric constant in "2 2"

mytext <- "5 5"

parse(text=mytext)
#> Error in parse(text = mytext): <text>:1:3: unexpected numeric constant
#> 1: 5 5
#>       ^

evaluate::evaluate(mytext)[[2]]
#> <simpleError: <text>:1:3: unexpected numeric constant
#> 1: 5 5
#>       ^>

sessioninfo::package_info("evaluate")
#>  package  * version date       lib source        
#>  evaluate   0.14    2019-05-28 [1] CRAN (R 4.0.4)
#> 
#> [1] C:/Program Files/R/R-4.0.4/library

message(paste("Error:", pander::evals(mytext)[[1]]$msg$errors))
#> Error: Unexpected numeric constant at character 3 in line 1: ` 5 5`

Thank you,

@barboulotte barboulotte changed the title Feature: option to choose between capture parsing error or console error Feature: option to choose between capture "parsing error" or "console error" Mar 21, 2021
@hadley
Copy link
Member

hadley commented Jun 14, 2024

I don't understand the question sorry. If you're still interested, you can try asking it a different way in a new issue.

@hadley hadley closed this as completed Jun 14, 2024
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

2 participants