Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-08 Thread Esteban Maringolo
Maybe the abstraction needed wraps everything within a single handler, but internally does a switch like statement dispatching to a particular error handler block. handledBlock exceptionDispatcher on: NotFoundError do: [:ex | ...]; on: MessageNotUnderstood do: [:ex | .. ].

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-08 Thread jtuc...@objektfabrik.de
Am 08.04.19 um 14:39 schrieb Richard O'Keefe: > > It's easy enough to add your own methods like > on: exn1 do: act1 on: exn2 do: act2 >     "An imperfect emulation of VAST's #when:do:when:do:" >     ^[self on: exn1 do: act1] on: exn2 do: act2 > > on: exn1 do: act1

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-08 Thread Tim Mackinnon
Thanks Richard - indeed it was that VisualAge Smalltalk pattern that I was remembering and looking for in Pharo, and was a bit surprised it wasn’t there - and hence thought there’re was possibly a different way. I might propose we add this, if no-one else comes up with a better alternative.

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-08 Thread Richard O'Keefe
It won't be fast because it creates multiple blocks, whereas a "native" version would not. To be honest I have not implemented exceptions in my Smalltalk yet, but I want to inline []on:do: constructions. The VAST system I have is 8.6.3, and it supports ANSI Exceptions. On Tue, 9 Apr 2019 at

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-08 Thread Esteban Maringolo
Richard, I was going to comment the #when:do:[when:do:] approach of VAST [1]. Why do you say it won't be fast? Because of the multiple exception handlers in the call stack? I think that some construct might be used to obtain the same as the #when:do:when:do: but using a chained approach

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-07 Thread Richard O'Keefe
VisualAge Smalltalk has, in addition to the standard #on:do:, #when:do:, ..., #when:do:#when:do:#when:do:#when:do:#when:do:, with the last four mapping to #whenOneOf:doMatching:, taking two arrays. It's easy enough to add your own methods like on: exn1 do: act1 on: exn2 do: act2 "An imperfect

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-07 Thread Sean P. DeNigris
Or I guess you don't even need dd here, just #handleMyErrorCase polymorphically - Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-07 Thread Sean P. DeNigris
Tim Mackinnon wrote > nothing else springs to mind Double dispatch w extension methods on the Exception classes? - Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-07 Thread Stephan Eggermont
Tim Mackinnon wrote: > > Thanks, I guess that makes sense, although it somehow looks a bit ugly > with the nested brackets.. but nothing else springs to mind so maybe I’ll > get used to it (and In my case I think it’s likely 2 or 3 different > exceptions) I think I prefer them to be somehow

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-07 Thread Tim Mackinnon
Thanks, I guess that makes sense, although it somehow looks a bit ugly with the nested brackets.. but nothing else springs to mind so maybe I’ll get used to it (and In my case I think it’s likely 2 or 3 different exceptions) Tim Sent from my iPhone > On 7 Apr 2019, at 20:43, Richard Sargent

Re: [Pharo-users] How to catch and handle multiple exceptions

2019-04-07 Thread Richard Sargent
On Sun, Apr 7, 2019, 12:13 Tim Mackinnon wrote: > Hi - I’m wondering what the best way for handling multiple exceptions is > in Pharo? > > It seems like we just have on:do: (where on is a single exception?). > > However, I think I’ve noticed that you can concatenate exceptions - so >