-
Notifications
You must be signed in to change notification settings - Fork 40
Description
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.