catch and I/O errors [message #42891] |
Wed, 02 March 2005 13:58 |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
Hi all,
is there any way to handle I/O errors with catch? What's the distinction
between I/O errors and other errors good for anyway?
In the IDL online help to "Controlling Errors Using CATCH" (e.g., in the
Windows help file, find the reference to CATCH, click on the link
"Controlling Errors", then "Controlling Errors Using Catch"), there is a
flow chart about how errors are handled. It clearly sais that in case of
an I/O error, but with *no* use of the ON_IOERROR routine, error control
goes back to CATCH.
But look at the following example (BTW, why is a type conversion error
an I/O error? I think, that question has been asked before ...):
PRO test_error
catch, error
IF error NE 0 THEN BEGIN
catch, /cancel
print, 'Caught!'
return
ENDIF
a = 'string'
b = fix(a)
END
IDL> test_error
% Type conversion error: Unable to convert given STRING to Integer.
% Detected at: TEST_ERROR 14
D:\HOME\HORNBERG\SCRATCH\IDL_SCRATCH\test_error.pro
The error handler doesn't catch at all. If I leave it out, it's all the
same. This is not what the help article states. Am I missing something?
How would I write an error handler which would handle I/O errors and
other errors consistently in one routine?
Thanks for your help,
Benjamin
|
|
|