Thank you very much!
inherits(res, "try-error") is what I was looking for!


On Thu, Oct 3, 2013 at 9:07 AM, Gabor Grothendieck
<ggrothendieck@gmail.com>wrote:

> On Thu, Oct 3, 2013 at 8:57 AM, Dimitri Liakhovitski
> <dimitri.liakhovitski@gmail.com> wrote:
> > Hello!
> >
> > I need to flag my operation as an error if it produces an error.
> >
> > For example, this expression produces an error:
> > test<-try(log("a"))
> > str(test)
> >
> > However, how can I proceed using the information contained in test
> object?
> > I am looking for something like:
> > if test is an error {do this and this}
> > But I am not sure how to do it.
> >
> > I tried:
> >
> > class(test) %in% "try_error"
> >
>
> Try this code:
>
> > res <- try(log("a"))
> Error in log("a") : non-numeric argument to mathematical function
> > if (inherits(res, "try-error")) cat(attr(res, "condition")$message, "\n")
> non-numeric argument to mathematical function
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>



-- 
Dimitri Liakhovitski

	[[alternative HTML version deleted]]

