I am exercising Catch routines to continue my widget program's event handlers running, as you advice, on the other hand by performing so I cannot form out someplace the errors come.
Is there a little method to receive an error trace back in a widget program that is exercising a Catch error handler?
FSC_SURFACE_ELEVATION_COLORS: Case statement found no matches.
Case statement found no matches.
Hi John,
Â
The main problem with Catch routines is that they engage your widget program for ever in the running mode. It is easy to put a simple "Help, /Traceback" in the Catch code, so that the root cause of the catch routine can be identified.
Â
Basically you need to find the event handler that is causing the error. Running the help command calling the stack would do the trick illustrated below:-
Â
  Help, Calls=callStack
  callingRoutine = (Str_Sep(StrCompress(callStack[1])," "))[0]
Â
Then print the last message that caused the error using the Last_Message keyword.The command looks as below:-
Â
  Help, /Last_Message, Output=traceback
  Print,''
  Print, 'Traceback Report from ' + StrUpCase(callingRoutine) + ':'
  Print, ''
  FOR j=0,N_Elements(traceback)-1 DO Print, "   " + traceback[j]
Â
It is a good practice to incorporate the error message code that we you have a general Catch error handler. General Catch Error Handler code lines below:
Â
Catch, theError
  IF theError NE 0 THEN BEGIN
   Catch, /Cancel
   void = Error_Message()
   RETURN
  ENDIF
Finally it is good idea to have the text message to be customized in order to find the exact cause of error line from your code. You can achieve that something like this:
Â
Traceback Report from FSC_SURFACE_ELEVATION_COLORS:
Â
   % Case statement found no matches.
   % Execution halted at:  FSC_SURFACE_ELEVATION_COLORS  388 C:IDLIDL54davidfsc_surface.pro
   %            $MAIN$ Â
You can print your own message
Â
IF test EQ 0 THEN Message, 'The test failed, my Man.', /NoName
Â
Hope this helps.
Â
Regards,
Â
Alice