[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Consensus on error handling with DLMs



Paul van Delst (paul.vandelst@noaa.gov) writes:

> p.s. I only turn this error checking on *after* debugging though - if code crashes I want
> to know the line number i crashed at rather than always returning with a failure.

You might want to try my ERROR_MESSAGE routine. It was
designed *exactly* for this reason. I wanted sensible
error handling *AND* I wanted traceback information
to tell me the line number of the error:

   http://www.dfanning.com/programs/error_message.pro

All of your code will remain the same, and your CATCH
error handler, which previously looked liked this:

  CATCH, error_status
  IF ( error_status NE 0 ) THEN BEGIN
    CATCH, /CANCEL
    MESSAGE, !ERROR_STATE.MSG, /CONTINUE
    RETURN, FAILURE
  ENDIF    

Will now look like this:

  CATCH, error_status
  IF ( error_status NE 0 ) THEN BEGIN
    CATCH, /CANCEL
    ok = ERROR_MESSAGE(/Traceback)
    RETURN, FAILURE
  ENDIF    

Cheers,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155