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: [email protected] [mailto:[email protected]]
> Im Auftrag von jim holtman
> Gesendet: Freitag, 26. November 2010 15:52
> An: Alla Bulashevska
> Cc: [email protected]
> Betreff: Re: [R] How to catch error message
> 
> ?try
> 
> On Fri, Nov 26, 2010 at 9:26 AM, Alla Bulashevska
> <[email protected]> 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.
> >
> > ______________________________________________
> > [email protected] 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?
> 
> ______________________________________________
> [email protected] 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.

______________________________________________
[email protected] 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.

Reply via email to