Error handling correction (Re: Different load behavior of error stuff under 4.0.1)

From: Shiro Kawai <shiro_at_lava.net>
Date: Sat, 09 Oct 1999 14:29:51 -1000

There are a couple of problems in error handling when you try to use
stk or snow in "batch" mode (i.e. giving scripting file to be evaluated
then exit). I think the attached patch solves them.

The first symptom is that stk complains it doesn't know "stk:report-error"
when you use stk in batch mode. This is caused because, when the user
specified file is loaded, report-error is already set as
(lambda args (apply STk:report-error args)) but the autoload of
STk:report-error is not yet established. I delayed definition of
report-error as well as the autoload stuffs in tk-init.stk

The second symptom is that when snow encounters an error and prints
out the message, it doesn't exit. It's annoying if you're writing
scripts.


*** Src/toplevel.c Sat Oct 9 14:24:43 1999
--- Src/toplevel.c.orig Fri Sep 3 10:21:32 1999
***************
*** 275,300 ****
    if (STk_arg_file) {
      STk_set_signal_handler(STk_makeinteger(SIGINT), Truth);
      STk_interactivep = 0;
!
! /* We need to capture error in loading the file */
! PUSH_ERROR_HANDLER
! {
! if (STk_load_file(STk_arg_file, FALSE, STk_selected_module) == Ntruth)
! panic("Cannot open file \"%s\".", STk_arg_file);
  
  #ifdef USE_TK
! if (Tk_initialized){
! STk_internal_eval_string("(tk-set-error-handler!)", 0, NIL); /* Do it late */
! Tk_MainLoop();
! }
  #endif
- }
- WHEN_ERROR
- {
- /* error message is already printed, so we just exit */
- exit(1);
- }
- POP_ERROR_HANDLER
      exit(0);
    }
    else
--- 275,289 ----
    if (STk_arg_file) {
      STk_set_signal_handler(STk_makeinteger(SIGINT), Truth);
      STk_interactivep = 0;
! if (STk_load_file(STk_arg_file, FALSE, STk_selected_module) == Ntruth)
! panic("Cannot open file \"%s\".", STk_arg_file);
  
  #ifdef USE_TK
! if (Tk_initialized){
! STk_internal_eval_string("(tk-set-error-handler!)", 0, NIL); /* Do it late */
! Tk_MainLoop();
! }
  #endif
      exit(0);
    }
    else
*** Lib/tk-init.stk Sat Oct 9 13:42:31 1999
--- Lib/tk-init.stk.orig Sun Sep 26 05:02:14 1999
***************
*** 356,362 ****
  
  
  (define (tk-set-error-handler!)
- (set! report-error (lambda args (apply STk:report-error args)))
    (autoload "error" STk:report-error bgerror))
  
  ;=============================================================================
--- 356,361 ----
***************
*** 381,387 ****
    ;; report-error as a kind of autoload (must be a closure, rather than an
    ;; autoload since C error function tests explicitely it is a closure before
    ;; applying its arguments
! (define report-error #f)
    
    ;; Global help functions which are defined when Tk is loaded
    (autoload "help" help STk:show-help-file)
--- 380,387 ----
    ;; report-error as a kind of autoload (must be a closure, rather than an
    ;; autoload since C error function tests explicitely it is a closure before
    ;; applying its arguments
! (define (report-error . args)
! (apply STk:report-error args))
    
    ;; Global help functions which are defined when Tk is loaded
    (autoload "help" help STk:show-help-file)
Received on Sun Oct 10 1999 - 02:26:35 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST