comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Hoping ON_IOERROR would catch errors in IDLs subroutines.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Hoping ON_IOERROR would catch errors in IDLs subroutines. [message #64937] Tue, 03 February 2009 19:49
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
M. Katz writes:

> I'm trying to understand why ON_IOERROR doesn't catch an error that
> occurs with writing an image to the disk. Here's an example where I
> attempt to write an image to an intentionally nonexistent folder (see
> below).
>
> When I run the program it breaks at WRITE_PNG instead of jumping down
> to BAD_IO. However, if I change the WRITE_PNG to an OPENW, then it
> catches the error and redirects the flow the BAD_IO.
>
> What is the proper protocol to catch file errors in routines that IDL
> provides, and handle them in the parent procedure?

I pretty much handle everything with CATCH. I've never
had a problem with it.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Hoping ON_IOERROR would catch errors in IDLs subroutines. [message #64938 is a reply to message #64937] Tue, 03 February 2009 15:40 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
M. Katz wrote:
> I'm trying to understand why ON_IOERROR doesn't catch an error that
> occurs with writing an image to the disk. Here's an example where I
> attempt to write an image to an intentionally nonexistent folder (see
> below).
>
> When I run the program it breaks at WRITE_PNG instead of jumping down
> to BAD_IO. However, if I change the WRITE_PNG to an OPENW, then it
> catches the error and redirects the flow the BAD_IO.

IDL must not be considering errors in WRITE_PNG "IO errors".

> What is the proper protocol to catch file errors in routines that IDL
> provides, and handle them in the parent procedure?

In general, CATCH catches errors in user or system routines. Try:

pro error_test1

catch, error
if (error ne 0L) then begin
catch, /cancel
print, 'i caught the error!'
return
endif

nonexistent_folder = '/pink/elephant/'
write_png, nonexistent_folder+'x.png', [[0b,1b],[1b,0b]]
print, 'All is well.'
end


--
www.michaelgalloy.com
Tech-X Corporation
Associate Research Scientist
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Hoping ON_IOERROR would catch errors in IDLs subroutines.
Next Topic: Accessing IDL from Java

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:24:41 PDT 2025

Total time taken to generate the page: 0.00494 seconds