From: Alex Aris
Subject: surviving ERRORs
Date: 
Message-ID: <a7nn2a$h0c$2@grapevine.wam.umd.edu>
   hi,

I need to know what to use if I want my program to SURVIVE
and continue after  an error (any kind, unbound, etc.) happens.

I tried to use "catch", but it returns to the top-level.
I don't want that. I want that it returns until where the 
error is caught and then continue from that point on.

   Can anybody give me a suggestion?
thanks,

alex

From: Barry Margolin
Subject: Re: surviving ERRORs
Date: 
Message-ID: <aBKn8.13$vN.482@paloalto-snr2.gtei.net>
In article <············@grapevine.wam.umd.edu>,
Alex Aris <·······@dc.umd.edu> wrote:
>   hi,
>
>I need to know what to use if I want my program to SURVIVE
>and continue after  an error (any kind, unbound, etc.) happens.
>
>I tried to use "catch", but it returns to the top-level.

Huh?  CATCH catches calls to THROW.  It has little to do with errors (you
might put a call to THROW in a condition handler, that's about it).

>I don't want that. I want that it returns until where the 
>error is caught and then continue from that point on.

Continue in what way?  Errors are usually signalled because the function
can't go on with the data it has.  For instance, if you try to access an
unbound variable, how do you expect it to go on by itself?  The expression
call that referred to the variable needs a value there.

You can use IGNORE-ERRORS to get out of the whole expression in which the
error occurred.

Some places that signal errors establish restarts that allow a handler to
supply alternate data.  For instance, when UNBOUND-VARIABLE is signalled,
there may be a restart that supplies a value to be used instead, and
another to assign a value to the variable and retry.  However, there's no
standardization of this.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Kent M Pitman
Subject: Re: surviving ERRORs
Date: 
Message-ID: <sfw4rj4law9.fsf@shell01.TheWorld.com>
·······@dc.umd.edu (Alex Aris) writes:

>    hi,
> 
> I need to know what to use if I want my program to SURVIVE
> and continue after  an error (any kind, unbound, etc.) happens.
> 
> I tried to use "catch", but it returns to the top-level.
> I don't want that. I want that it returns until where the 
> error is caught and then continue from that point on.
> 
>    Can anybody give me a suggestion?

Read the chapter in CLHS on the condition system:

 http://www.xanalys.com/software_tools/reference/HyperSpec/Front/index.htm

See also these two papers, which contain conceptual background on the
design of the condition system:

 http://world.std.com/~pitman/Papers/Exceptional-Situations-1990.html
 http://world.std.com/~pitman/Papers/Condition-Handling-2001.html
From: Coby Beck
Subject: Re: surviving ERRORs
Date: 
Message-ID: <xpLn8.207077$kb.11591115@news1.calgary.shaw.ca>
"Alex Aris" <·······@dc.umd.edu> wrote in message
·················@grapevine.wam.umd.edu...
>    hi,
>
> I need to know what to use if I want my program to SURVIVE
> and continue after  an error (any kind, unbound, etc.) happens.
>

Check out handler-case as an easy jumping-off point.  ignore-errors is a
dangerous trap and will make your debugging a nightmare because it will get
buried and you will forget it.  Only use it if you *really* need it around
small bits like (perhaps) inside error handling code.

Try something like:

(defun my-crash-proof-program (input)
  (handler-case
      (let ((data (foo-bar input)))
        (hairy-computation data))
    (error (e)
           (ignore-errors
             (report-to-authorities e)))))

--
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Alex Aris
Subject: Re: surviving ERRORs
Date: 
Message-ID: <a7op72$ss3$1@grapevine.wam.umd.edu>
Coby Beck (·····@mercury.bc.ca) wrote:

: "Alex Aris" <·······@dc.umd.edu> wrote in message
: ·················@grapevine.wam.umd.edu...
: >    hi,
: >
: > I need to know what to use if I want my program to SURVIVE
: > and continue after  an error (any kind, unbound, etc.) happens.
: >

: Check out handler-case as an easy jumping-off point.  ignore-errors is a
: dangerous trap and will make your debugging a nightmare because it will get
: buried and you will forget it.  Only use it if you *really* need it around
: small bits like (perhaps) inside error handling code.

It seems that I really need it. ignore-errors was the best (and simplest)
choice among all of them as I don't care about the error.
(They are not my errors, by the way, and I won't debug them,
 only need to continue to give points to students when they crash
 my grading program:)

: Try something like:

: (defun my-crash-proof-program (input)
:   (handler-case
:       (let ((data (foo-bar input)))
:         (hairy-computation data))
:     (error (e)
:            (ignore-errors
:              (report-to-authorities e)))))

Thanks for your explanation  and for 
all you guys who answered my question. 

I really appreciate it.

alex  

: --
: Coby Beck
: (remove #\Space "coby 101 @ bigpond . com")