[R] catching errors in RNetCDF
Jannis
bt_jannis at yahoo.de
Thu Dec 6 14:26:50 CET 2012
Thanks Michael and Pascal for your replies,
sorry if I did not formulate my post precisely enough. My example code
was meant to produce an error to demonstrate the behaviour that I
interpretet as "not causing real R errors". Also without the try()
funtion around it to me it seems that just some message is printed
without R recognising this as an error. If this line of code would be
one line in a long script, the following lines would still be executed
and debugging mechanisms like options(error=dump.frames) are not
invoked. It is certainly possible to debug this error, it is just really
hard to trace it down if it happens in long and complicated functions.
In case there is an easy fix for this, I am happy to learn about it.
Otherwise this may be due to the way that RNetCDF handles these errors
and harder/impossible to fix. In this case I would consider this post
closed. I had some contact with the author of the package in the
meantime. In case my first post reads as a critique to the author I
would like to apologize. It is clear to me that packages are written
voluntarily and with a lot of enthusiasm for the open source idea so I
certainly do not want to critisise anyone for sharing his code!
Thanks a lot
Jannis
On 06.12.2012 12:53, Michael Sumner wrote:
> Do you want to cause an error or catch one? Try removing the try() and
> see if that helps.
>
> This has nothing to do with RNetCDF you could as easily have caught
> another more basic error.
>
> On Thursday, December 6, 2012, Jannis wrote:
>
> Hi Pascal,
>
> Well, as i see it, this is no error, just a simple message printed
> to the screen claiming that it is an error. All the mechanisms in R
> to handle errors (e.g a stop of code execution etc) are, however,
> not initiated.
>
>
> Cheers
> Jannis
>
> On 06.12.2012 02:53, Pascal Oettli wrote:
>
> Hi,
>
> When I try your example, I simply get an error:
>
> > library(RNetCDF)
> > con <- create.nc <http://create.nc>('test.nc <http://test.nc>')
> > test <- try(var.get.nc <http://var.get.nc>(con, 'dummy'))
> Error : NetCDF: Variable not found
>
> Regards,
> Pascal
>
>
> Le 05/12/2012 22:08, Jannis a écrit :
>
> Dear R community,
>
>
> I quite frequently run into errors while using the RNetCDF
> package which
> do not seem to be recognised as normal R errors and, hence,
> do not stop
> the execution of the code making it hard to debug the code.
>
> Consider, for example:
>
> library(RNetCDF)
> con <- create.nc <http://create.nc>('test.nc <http://test.nc>')
> test <- try(var.get.nc <http://var.get.nc>(con, 'dummy'))
>
>
> In this case, some sort of error message is printed to the
> screen, but R
> does not recognise this as an error. Is there any way to
> solve this?
>
> I contacted the author of the package but it seems that
> there will be no
> solution from that side.
>
>
> Any Ideas?
>
>
> Cheers
> Jannis
>
> ________________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/__listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide
> http://www.R-project.org/__posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible
> code.
>
>
> ________________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/__listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide
> http://www.R-project.org/__posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Michael Sumner
> Hobart, Australia
> e-mail: mdsumner at gmail.com <mailto:mdsumner at gmail.com>
More information about the R-help
mailing list