Skip to content
Prev 60538 / 63421 Next

message(<cond>) and warning(<cond>) circumvent calling handlers and signal the original class, e.g. an error

Hi,

There is the same issue with stop():
<simpleWarning: careful>

I very recently stumbled upon this, when a warning was re-raised as an error, which was then not caught by an outer try():
+   tryCatch(warning("careful"), warning = function(w) stop(w)),
+   silent = TRUE
+ )
Error in doTryCatch(return(expr), name, parentenv, handler) : careful

I would also like to see this behavior changed. I think that stop() should always signal an error, warning() a warning and message() a message.

Best,
Andreas

2022-03-01 19:38 GMT+01:00 "Henrik Bengtsson" <henrik.bengtsson at gmail.com>: