Skip to content

warnings are suppressed in r_session$call() #306

@mcol

Description

@mcol

It would be nice if the status code marked that a warning had occurred. At the moment, one can at best get the warning message from stdout, but code is still 200, so there's no way of differentiating a valid output from a warning.

For example:

rs <- callr::r_session$new()
rs$call(function() warning("warning message"))
rs$read()

# $code
# [1] 200
# 
# $message
# [1] "done callr-rs-result-2b3a9589b28e4"
# 
# $result
# [1] "warning message"
# 
# $stdout
# [1] ""
# 
# $stderr
# [1] ""
# 
# $error
# NULL
# 
# attr(,"class")
# [1] "callr_session_result"

Using a different error code or adding a warning field to the results would allow to retrieve whether a warning had occurred.

The only workaround I've found is to turn the warnings into options within the session with rs$run(function() options(warn = 2)), and then parse the error field to see if it contains the string "(converted from warning)". This is quite clumsy, it's effective only in an English locale, and with this it's impossible to keep track of cases when both warnings and errors occur.

In any case, the handling of warnings by callr should be documented.

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