X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 25 Apr 2008 10:32 AM by  anon
capturing error messages while in IDL execution mode
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
25 Apr 2008 10:32 AM
    Hello, Is it possible to capture an execution error (lets say IDL encounters a typo or something like that) and send it to a GUI ? Currently if IDL encounters something it automatically displays some error message on one of the lower windows in the IDL development environmen. I would like to capture that same message and send it to a GUI or a message_dialog box. I looked at the "on_error" function but did not find what I am looking for. Thanks!

    Deleted User



    New Member


    Posts:
    New Member


    --
    25 Apr 2008 10:32 AM
    Cecilia, CATCH is the more modern and best IDL command to use to catch an error for subsequent sending to an IDL DIALOG_MESSAGE message box. I paste an example below. The critical elements of error-handling, which you can subsequently look at in online help are CATCH and "CATCH, /CANCEL", the '!ERROR_STATE' structure, "HELP, /TRACEBACK", ON_ERROR and "MESSAGE, /REISSUE_LAST". ; This example is demonstrating three things: ; - the general syntax and use of a CATCH block which can ; display caught error messages in a system MessageBox ; - the more specialized syntax of a CATCH statement which is ; looking for a very specific error ; - the syntax of error handling which allows all other errors to ; be passed up the "call chain" PRO ex_catch_error_in_messagebox on_error, 2 ; Pass unhandled errors up to caller catch, errno if errno ne 0 then begin catch, /CANCEL ; Handle only undefined variable error if !error_state.name eq 'IDL_M_UNDEFVAR' then begin help, /TRACEBACK, OUTPUT=helpOutput void = dialog_message([!error_state.msg, 'Traceback Info:', $ helpOutput], /ERROR) void = dialog_message(['Creating default value of', $ '-999.0 for undefined variable'], /INFO) myVar = -999.0 endif else begin ; Propagate other errors up to the caller message, /REISSUE_LAST ; Command to effect the propagation endelse endif ; Will trigger undefined variable error on first attempt print, 'myVar = ', myVar ENDJames Jones
    You are not authorized to post a reply.