On Tue, May 20, 2008 at 01:37:21PM +0200, Jon Kleiser wrote:
> !? (load (if (setq *Ctry Ctry) (pack "@loc/" @) "@loc/NIL"))
> loc/NO open: No such file or directory
> Does Pico Lisp have an error handling mechanism that can handle
> errors like this?
Indeed, this is a long-missing feature.
Originally, I intended to introduce it in picoLisp-3.0 (the 64-bit
version). But now I saw that it basically required only a few lines in
the error handler, so I put it into the current (testing) release.
Now you can catch such errors with the normal 'catch' function.
When 'catch' is called with a list of symbols (as opposed to a single
tag symbol, when setting up a catch environment for 'throw'), it will
catch all errors whose messages contain one of these strings as a
So, if you have an error like
: (in "doesntExist" (foo))
!? (in "doesntExist" (foo))
doesntExist open: No such file or directory
you can catch it with
: (catch '("No such file") (in "doesntExist" (foo)))
-> "No such file"
Note that 'catch' returns the matched substring when it caught such an
error. Therefore, this return value can be used to react appropriately.
(catch '("No such file" "Undefined" "expected")
("No such file"
(handleNonExisting File) )
(handleUndefined Function) )
(handleBadArgument Type) )
(handleTheCorrectValue @) ) )
The 'T' clause of the above 'case' statement works because '@' holds the
return value of the successful execution of 'doSomething'.
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]