You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/03/15 23:02:00 UTC
[jira] [Updated] (ARROW-11700) [R] Internationalize error handling
in tidy eval
[ https://issues.apache.org/jira/browse/ARROW-11700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated ARROW-11700:
-----------------------------------
Labels: pull-request-available (was: )
> [R] Internationalize error handling in tidy eval
> ------------------------------------------------
>
> Key: ARROW-11700
> URL: https://issues.apache.org/jira/browse/ARROW-11700
> Project: Apache Arrow
> Issue Type: New Feature
> Components: R
> Reporter: Neal Richardson
> Assignee: Neal Richardson
> Priority: Minor
> Labels: pull-request-available
> Fix For: 4.0.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> We have
> {code}
> tryCatch(eval_tidy(expr, mask), error = function(e) {
> # Look for the cases where bad input was given, i.e. this would fail
> # in regular dplyr anyway, and let those raise those as errors;
> # else, for things not supported by Arrow return a "try-error",
> # which we'll handle differently
> msg <- conditionMessage(e)
> # TODO: internationalization?
> if (grepl("object '.*'.not.found", msg)) {
> stop(e)
> }
> if (grepl('could not find function ".*"', msg)) {
> stop(e)
> }
> invisible(structure(msg, class = "try-error", condition = e))
> })
> {code}
> and tests for this behavior, but the tests are skipped because they only match correctly in an English locale because these base R messages are translated.
> We can generate these regular expressions dynamically by triggering the R errors on a known nonexistent object:
> {code}
> > tryCatch(X_____X, error = function(e) conditionMessage(e))
> [1] "object 'X_____X' not found"
> > tryCatch(X_____X(), error = function(e) conditionMessage(e))
> [1] "could not find function \"X_____X\""
> > sub("X_____X", ".*", tryCatch(X_____X, error = function(e) conditionMessage(e)))
> [1] "object '.*' not found"
> {code}
> And this will respect i18n:
> {code}
> > Sys.setenv(LANGUAGE="FR_fr")
> > sub("X_____X", ".*", tryCatch(X_____X, error = function(e) conditionMessage(e)))
> [1] "objet '.*' introuvable"
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)