Navigation:  Programmer's Reference >

The Global Error Handler

 

 

Previous pageReturn to chapter overviewNext page

Before you create your diagrams you must regaister two global error handlers within your main GRAPH-XT program.

There are two main global error handlers with the following purposes:

1. Handling unhandled errors in your own GRAPH-XT code

2. Handling fatal errors within the GRAPH-XT library

Particulary the second fatal error handler is most important: It handles errors where DPlot does not respond to commands anymore (which very rarely happens but *if* it happens your program won't be able to gracefully recover from such errors!). It uses a HTBasic SIGNAL (default: SIGNAL 15) in order to signal the main program that the communication between GRAPH-XT and DPlot is broken. In this case the main program is able to clean up resources and go back to a normal operating state.

Info3

Please note:

Registering the global error handlers is mandatory !

Please always use the following structure for the error handler definition and place it at the beginning of your program:

!--------------------------------------------------------------------------------

! Global error handler definitions

ON ERROR RECOVER Dde_err_handler                       ! Global error handler

ON SIGNAL FNDplot_errorhand,15 RECOVER Dde_err_hand_c ! Fatal error handler

!--------------------------------------------------------------------------------

In case SIGNAL 15 is already used within your program you may also define a different SIGNAL number using the function FNDplot_errorhand before you register the SIGNAL handler:

Dummy=FNDplot_errorhand(12)  ! define SIGNAL 12 as the fatal error signal

... and always place the following code at the very end of your code within the same context like the global error handler definition:

Finish: ! terminate all DDE connections and free up resources

CALL Dplot_quit(Sys_chn,Result,Verb_,1,1,Dplot_quit)

PRINT PEN 4

DISP " Program finished."

PRINT PEN 1

SUBEXIT

!

!===================== Global error handler =====================================

Dde_err_handler: !

BEEP

PRINT "**** Global Error Handler ****"&Crlf$&Crlf$&ERRM$

GOTO Finish

!

Dde_err_hand_c: ! Fatal GRAPH-XT library error (DPlot does not respond)

PRINT

PRINT PEN 2

PRINT " **** GRAPH-XT FATAL Error Handler ****"

PRINT PEN 1

PRINT " DPlot not responding, program aborted."

Dplot_quit=0       ! Dplot most likely crashed, so do not try to quit it again

GOTO Finish

!=================================================================================