Hoping ON_IOERROR would catch errors in IDLs subroutines. [message #64939] |
Tue, 03 February 2009 15:17 |
M. Katz
Messages: 69 Registered: May 2005
|
Member |
|
|
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?
-M. Katz
pro error_test1
ON_IOERROR, BAD_IO
nonexistent_folder = '/pink/elephant/'
WRITE_PNG, nonexistent_folder+'x.png', [[0b,1b],[1b,0b]]
PRINT, 'All is well.'
return
BAD_IO: begin
ON_IOERROR, NULL
PRINT, 'I caught the error!'
PRINT, !error_state.msg
end
return
end
|
|
|