[plt-scheme] raising / handling errors

From: Greg Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Mon Feb 27 17:39:30 EST 2006

I know(?) how to use with-handlers to catch exististing exceptions, and
in fact, I do this (now) in my read/eval/print loop. But it is not all
clear (to me) how to go about raising exceptions and handling them. I
am aware of raise and error, but I'd like to be able to raise an
exception which will be caught by a handler I install. I recall reading
that, say, exn:fail:contract:arity corresponds to the predicate
exn:fail:contract:arity? but can I create new types of exceptions (such
as for errors detected during syntactic analysis, unbound symbols in
the environment managed by the evaluator, not by Scheme)? What kind of
predicate should be used in conjunction with raise? Is it possible to
include specific error messages and make them available to the handler
(the reason I was trying to use raise, in fact)?

===
Gregory Woodhouse  <gregory.woodhouse at sbcglobal.net>
"All truth passes through three stages: First, it is ridiculed.
Second, it is violently opposed. Third, it is accepted as
being self-evident."
--Arthur Schopenhauer


Posted on the users mailing list.