Skip to content
Prev 88654 / 398500 Next

handling warning messages

On 3/16/06, Martin Morgan <mtmorgan at fhcrc.org> wrote:
BE CAREFUL!  When a condition, such as warnings and errors, are caught
by tryCatch() the expression that follows are NOT evaluated!  This is
probably not what you want/expected.

tryCatch({
  print(1)
  warning("a warning")
  print("We never get here!")
}, warning=function(w) {
  paste("Caught:", conditionMessage(w))
})

[1] 1
[1] "Caught: a warning"

/Henrik
--
Henrik Bengtsson
Mobile: +46 708 909208 (+1h UTC)