[BUG?] Exception handle

Anthony Hannan ajh18 at cornell.edu
Thu Mar 4 00:24:54 UTC 2004


"ICHIKAWA, Yuji" <y.ich at f3.dion.ne.jp> wrote:
> [1/0] ifCurtailed: [Transcript show: 'exception']
> doesn't work on Squeak 3.6-#5429, I guess.
> Is there anything wrong?

No.

The debugger halts the process while the ifCurtailed: context is still
on the stack, so the ifCurtailed: context hasn't been popped yet
(curtailed or simply returned).  Furthermore, ifCurtailed: only executes
its argument if its context is curtailed (skipped over because of remote
return).  When you hit proceed on the debugger you are resuming through
the error (not remote returning) so the ifCurtailed: context is not
curtailed and hence its argument is not executed.  If hit abandon on the
debugger you are remote returning to the bottom of the stack (ending the
process) so the ifCurtailed: context is curtailed and hence its argument is
executed.  If you change ifCurtailed: to ensure: you will see that its
argument is always executed whether curtailed or simply returned.

If you catch the error and you do a return in your handler (which is a
remote return to the on:do: caller) then the ifCurtailed: context will
be curtailed and you will see its argument executed.  If you do a resume
in your handler you will resume where the error happened just like
hitting proceed on the debugger and the ifCurtailed: context will not be
curtailed.  Check out the following examples:

[[1/0] ifCurtailed: [Transcript show: ' exception1']] on: Error do: [:ex
| ex return].
[[1/0] ifCurtailed: [Transcript show: ' exception2']] on: Error do: [:ex
| ex resume].
[[1/0] ensure: [Transcript show: ' exception3']] on: Error do: [:ex | ex
resume].

Transcript will print exception1 and exception3.

Cheers,
Anthony



More information about the Squeak-dev mailing list