Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@barboulotte

Description

@barboulotte

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions