Unless I'm missing something, (catch) works a bit better
than I'd have hoped. It not only prevents the normal
error messages appearing, it hides any clue as to what
went wrong. For example:
Welcome to the STk interpreter version 3.99.4 [Linux-2.X-ix86]
Copyright © 1993-1999 Erick Gallesio - I3S - CNRS / ESSI <eg_at_unice.fr>
STk> (open-input-file "not-there")
*** Error:
could not open file: "not-there"
Current eval stack:
__________________
0 (open-input-file "not-there")
STk> *last-error-message*
"could not open file"
STk> (catch (/ 1 0))
#t
;;;
;;; What I'd like at this point is something I
;;; can use to tell the user "divide by zero error"
;;; and then carry on. Instead I get:
;;;
STk> *last-error-message*
"could not open file"
;;;
;;; however, without the (catch), I get:
;;;
STk> (/ 1 0)
*** Error:
/: not a valid number: 0
Current eval stack:
__________________
0 (/ 1 0)
;;;
;;; and
;;;
STk> *last-error-message*
"/: not a valid number"
Digging through the sources, it seems *last-error-message*
is set as part of the message printing, when I'd prefer
it be done during the error catching.
The following patch seems to fix things (WARNING: on my
home machine - I don't have enough disc space currently
to try it out on this machine! In fact, I don't even have
space to untar the whole STk distribution.):
--- orig/error.c Thu Jul 1 13:35:13 1999
+++ new/error.c Thu Jul 1 13:36:13 1999
_at_@ -138,18 +138,19 @@
}
POP_ERROR_HANDLER;
- /*
- * Retain the arguments of this error in global Scheme variables
- */
Flush(STk_curr_oport); Flush(STk_curr_eport);
- STk_define_variable("*last-error-message*", STk_makestring(message), NIL);
- STk_define_variable("*last-error-arg*", x, NIL);
}
void STk_err(char *message, SCM x)
{
STk_reset_eval_hook();
+
+ /*
+ * Retain the arguments of this error in global Scheme variables
+ */
+ STk_define_variable("*last-error-message*", STk_makestring(message), NIL);
+ STk_define_variable("*last-error-arg*", x, NIL);
/* Print a message if the error is not ignored */
if (!(STk_err_handler->context & ERR_IGNORED)) {
in other words, in error.c, take the last couple of lines
(and their associated comment) from print_message() and
move them down into STk_err().
Have I broken anything?
Have I missed a don't-mess-with-the-C way of
getting what I want?
imw
Received on Thu Jul 01 1999 - 17:15:55 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST