[squeak-dev] Re-signalling an already signaled exception
asqueaker at gmail.com
Fri Feb 4 23:11:35 UTC 2022
Here's a motivation example:
> [1/0] on: Error do: [:ex |
> [ex signal] on: ZeroDivide do: [Transcript show: #ZeroDivide]
> Would you expect this code to work and pick up the ZeroDivide handler?
> The point or a use case is to provide additional (finer, more specific)
> handlers inside the general handler rather than wrap the general handler
> inside more specific handlers. More specific handlers can even be inside a
> method so the readability would not degrade.
I was able to do it by creating a new exception instance and signaling it:
[1/0] on: Error do: [: err |
[err copy signal] on: ZeroDivide do: [Transcript show:
I don't know about #copy, though, you might want to implement your own
special #freshCopy that throws out the signalContext, handlerContext and
outerContext, but the above "worked". :)
> Does this make sense?
Another option seems you could dispatch your handler (or double-dispatch)
to the signaled Exception.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev