I'm thinking that something is suppressing warnings by setting options(warn=-1)
, and generating a warning. I can simulate the behaviour you are seeing here.
Create a function that generates a warning and returns 99 but with the warning suppressed by options:
> foo=function(){o=options()$warn; options(warn=-1);warning("Yikes!");options(warn=o);return(99)}
That seems to run nicely:
> foo()
[1] 99
And I can run it in a simple tryCatch
:
> tryCatch(foo())
[1] 99
But the warning gets trapped if I add a warning
clause:
> tryCatch(foo(),warning=function(w){message(w)})
Yikes!>
Although it still seems to run without warnings:
> foo()
[1] 99
I'm not sure what the solution is... Sorry... Perhaps getting whoever wrote the code that tries to suppress the warning to rewrite it to use suppressWarnings
instead:
> foo=function(){suppressWarnings({warning("Yikes!")}) ; return(99)}
> foo()
[1] 99
> tryCatch(foo(),warning=function(w){message(w)})
[1] 99