Hi, in help("message", package = "base"), we can read:
Description: 'message' is used for generating 'simple' diagnostic
messages which are neither warnings nor errors, but nevertheless
represented as conditions.
From this, I conclude that message() should generate a condition that
are neither warning nor errors.
However, the following signals a condition of class 'error':
e <- simpleError("boom!\n")
message(e)
boom!
This can be seen if we do:
res <- tryCatch(message(e), condition = identity)
res
<simpleError: boom!
This stems from message(e) using signalCondition(e) internally.
Another problem with this behavior is that message(e) cannot be suppressed:
suppressMessages(message(e))
boom!
or captured with calling handlers, e.g.
res <- withCallingHandlers(message(e), condition = identity)
NULL
If we replace e <- simpleError("boom") with e <-
simpleWarning("careful"), we see a similar behavior. These problems
exist also with warning(e). The current behaviors prevent functions
from capturing and relaying message(<error>), message(<warning>), and
warning(<error>).
I'm happy to post a bug report to <https://bugs.r-project.org/>.
/Henrik
PS. BTW, it looks like some recent "..." tweaks to the warning() and
stop() code could be applied also to message().