Re: Error Handling Advice [message #82709 is a reply to message #82708] |
Mon, 14 January 2013 10:30   |
Matthew Argall
Messages: 286 Registered: October 2011
|
Senior Member |
|
|
Ok, I think I have reasoned with myself enough to know when to use ON_ERROR, 2 and when to use CATCH, but most CATCH blocks that I see just print an error message and return to the calling program, anyway, without doing anything special.
For example, take the following
-----------%<----------------
CATCH, Error_status
IF Error_status NE 0 THEN BEGIN
CATCH, /CANCEL
PRINT, 'Error index: ', Error_status
PRINT, 'Error message: ', !ERROR_STATE.MSG
RETURN
ENDIF
-----------%<----------------
Is there any reason for not using ON_ERROR, 2 in this case?
From what I gather, the CATCH blocks are normally used to make a program "fail gracefully", in that it resets the device and color table, closes files, frees pointers, etc. But without anything to reset, is ON_ERROR, 2 sufficient?
I guess I will start with some with trial and ::ehem:: error ;-)
|
|
|