Re: [R] help: error handling in try

2008-09-11 Thread Andy Zhu
unction to raise error then one needs another function on top of it). Not sure why try doesn't work though. best. --- On Wed, 9/10/08, jim holtman <[EMAIL PROTECTED]> wrote: From: jim holtman <[EMAIL PROTECTED]> Subject: Re: [R] help: error handling in try To: [EMAIL PROTECTE

Re: [R] help: error handling in try

2008-09-10 Thread jim holtman
} > .Internal(seterrmessage(error.old)); > return(ret); > } > > adate='12/2000'; > fun=as.Date; > format='%b %Y'; > > is.Date(adate,fun,format); # false > > library(zoo); > fun=as.yearmon; > format='%m/%Y'; >

Re: [R] help: error handling in try

2008-09-10 Thread Andy Zhu
t); # true Cheer. --- On Wed, 9/10/08, jim holtman <[EMAIL PROTECTED]> wrote: From: jim holtman <[EMAIL PROTECTED]> Subject: Re: [R] help: error handling in try To: [EMAIL PROTECTED] Cc: r-help@r-project.org Date: Wednesday, September 10, 2008, 8:11 AM Why don't you use 'try&#x

Re: [R] help: error handling in try

2008-09-10 Thread jim holtman
Why don't you use 'try' in this fashion: > f.error <- function(x) if (x == 1) stop('error') > > value <- try(f.error(1)) Error in f.error(1) : error > if (inherits(value, 'try-error')) cat("Got this error:", value) else print > ("no error") Got this error: Error in f.error(1) : error > value <- t

[R] help: error handling in try

2008-09-09 Thread Andy Zhu
First time to post and searched archive for this problem with no clue. My version is 2.5.1. Below is a function to check if a given date is a valid date to a given date function object. It uses try (also tried tryCatch but with same problem). When given an invalid date, I am hoping try will gen