evaluate icon indicating copy to clipboard operation
evaluate copied to clipboard

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

Open barboulotte opened this issue 4 years ago • 0 comments

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 avatar Mar 21 '21 18:03 barboulotte