try.result <- try(your.expr)
if(inherits(try.result, "try-error")){
do.what.needs.to.be.done.here()
} else {
cat("OK", sep="\n")
}
Or have a look at ?tryCatch
Cheers,
Janko
> -----Urspr?ngliche Nachricht-----
> Von: r-help-bounces at r-project.org [mailto:r-help-bounces at
r-project.org]
> Im Auftrag von jim holtman
> Gesendet: Freitag, 26. November 2010 15:52
> An: Alla Bulashevska
> Cc: r-help at r-project.org
> Betreff: Re: [R] How to catch error message
>
> ?try
>
> On Fri, Nov 26, 2010 at 9:26 AM, Alla Bulashevska
> <alla.bullashevska at fdm.uni-freiburg.de> wrote:
> > Dear R users,
> > i would like to catch error message (coming after
> > unsuccessful database query) so that the script will
> > process further. How can I manage this?
> > Thank you in Advance,
> > Alla.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.