Fun with Number readFrom: What should we do ?

nicolas cellier ncellier at ifrance.com
Thu Apr 27 12:39:30 UTC 2006


> But with mine, you can also have a global exception handling:
>   [value1 := Number readfrom: aStream.
>     value2 := Number readFrom: aStream]
>       ifError: [global handler block]
>
> Maybe a new exception class is better than Error, but i do not take this
> responsability alone.
>   [value1 := Number readfrom: aStream.
>     value2 := Number readFrom: aStream]
>       on: NumberReadError do: [:exc | global handler block]
>
> Hope i convinced someone.
>
> Nicolas

i hadn't noticed the typo (lowercase f instead of F in readFrom:) in my 
example, but this is an excellent explanation why a specific error is better.

The first block will catch the Number class doesNotUnderstand: #readfrom: , 
That is it will catch my programming error...
That is we always get the exception handling block even with a good stream...

Nicolas




More information about the Squeak-dev mailing list