Skip to content

catching errors in RNetCDF

6 messages · Jannis, Pascal Oettli, Michael Sumner

#
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('test.nc')
test <- try(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
#
Hi,

When I try your example, I simply get an error:

 > library(RNetCDF)
 > con <- create.nc('test.nc')
 > test <- try(var.get.nc(con, 'dummy'))
Error : NetCDF: Variable not found

Regards,
Pascal


Le 05/12/2012 22:08, Jannis a ?crit :
#
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 Jannis,

The variable is not found. That is why there is an error. Every time I 
get an error message using 'RNetCDF', I am able to debug the code.

Regards,
Pascal


Le 06/12/2012 20:41, Jannis a ?crit :
#
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: