View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

How to handle runtime errors?

bruzzone wrote on Aug 02, 2011

Hi, perhaps somebody has asked this before, but since the forum search returns the '404 not found', I would like to ask it anyway.
Is there a way to handle runtime errors in a script?
I mean, if some task fails to do something, like trying to open a file
that is not present or something more intrinsic(cause the former could be done by using if(!access("file")) before ) like some error computation when using imalign, is there a way of continuing using a script handling that specific case as say, a conditional? If an error is returned in performing a given task within a script, change some parameters and run that task again.
thanks
Best regards!

seba

Mike Fitzpatrick wrote on Aug 02, 2011

Error handling in the CL is done using the 'iferr' expression, e.g.


    iferr {                            
        <block of statements>             
    } then {                            
        <block of error stmts>                
    }


So an error in any of the tasks in the first block will cause statements in the second block to be executed, otherwise the second block is ignored. For more details on this, see the explanation in the iraf$pkg/ecl/Notes.ecl file

Last post on Aug 02, 2011