[squeak-dev] The Inbox: Collections-mt.812.mcz
marcel.taeumel
Marcel.Taeumel at hpi.de
Fri Jan 25 08:21:50 UTC 2019
Hi, there.
I commited this proposal by accident to Trunk when merging the size-check
changes by JH.
I will implement your suggestions. And add some tests. :-)
Best,
Marcel
Eliot Miranda-2 wrote
> On Tue, Dec 18, 2018 at 1:20 PM Chris Muller <
> asqueaker@
> > wrote:
>
>> Hi Marcel,
>>
>> I've needed something like this before too, but since I also wanted to
>> work more with the Error's, I simply provided an additional Block for
>> the inner-layer which took each Error as the argument. Then my
>> calling could log to Transcript or add to a separate Collection (since
>> I prefer to view "object messages" in an Explorer instead of only text
>> in the Transcript), and nicely avoids the unpleasant dependency on
>> Transcript.
>>
>> I also think it could just trap Error (or MessageNotUnderstood) since
>> that is the stated intended usage. I think if one needed to specify a
>> custom exceptionOrExceptionSet, then it seems like they'd probably
>> just write normal error-handling code.
>>
>
> +1. I was going to suggest the same thing. It's much more flexible to
> factor the inner two methods as:
>
> try: aBlock ignore: exceptionOrExceptionSet
> "Evaluate aBlock with each of the receiver's elements as the
> argument. On error, skip that element and continue."
>
> ^self try: aBlock ignore: exceptionOrExceptionSet ifException: nil!
>
> try: aBlock ignore: exceptionOrExceptionSet ifException: unaryBlockOrNil
> "Evaluate aBlock with each of the receiver's elements as the
> argument. On error, skip that element and continue."
>
> ^ self do: [:ea |
> [aBlock value: ea]
> on: exceptionOrExceptionSet
> do: [:err | unaryBlockOrNil ifNotNil:
> [unaryBlockOrNil
> value: err]]]!
>
> then
>
> try: aBlock ignore: exceptionOrExceptionSet logged: aBoolean
> ^self try: aBlock ignore: exceptionOrExceptionSet ifException:
> (aBoolean
> ifTrue: [[:err| Transcript showln: err messageText]])
>
> _,,,^..^,,,_
> best, Eliot
--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html
More information about the Squeak-dev
mailing list
|