Exception bug? (was Re: Can't get Squeak Plugin to work under Linux)

Paul McDonough wnchips at home.com
Sun May 6 21:39:55 UTC 2001


Fair enough, I'm not a 3.x user just yet.  I believe your tests at face value.

But while in Bert's particular case the result may be the same, there
are definitely potential differences when it comes to resume:, return:,
and just letting the handler block "fall off", viz.

	| a |
	a := [self doSomethingSillyThatCausesAnError.
		3]
			on: SillyError
			do: [:ex | ex resume: nil]
=> this gets a = 3, assuming the exception was resumable.

	| a |
	a := [self doSomethingSillyThatCausesAnError.
		3]
			on: SillyError
			do: [:ex | ex return: nil]
=> this gets a = nil.

	| a |
	a := [self doSomethingSillyThatCausesAnError.
		3]
			on: SillyError
			do: [:ex | nil]
=> oog! behaviour unspecified in ANSI! in Squeak implementation, as with
most others, this is the equivalent of using [:ex | ex return: nil]. 
*BUT* that is just "luck", nothing to do with the nil in the block.  So
even if you put a really great handler in there, but don't include an
explicit handler (return:, resume:, resignalAs:, yadaYada), you're still
stuck getting a = nil from:

	| a |
	a := [self doSomethingSillyThatCausesAnError.
		3]
			on: SillyError
			do: [:ex | self calculateTheSingleAmazingNumberThatCausesWorldPeaceToArrive]

Paul "I can't be bothered to test what I assert, but I know that someone
out there will publicly humiliate me if I'm wrong (again), isn't Open
Source beautiful!" McDonough ;-)

Bob Arning wrote:
> 
> Paul,
> 
> On Sun, 06 May 2001 09:27:46 -0700 Paul McDonough <wnchips at home.com> wrote:
> >Actually I think Bert wants
> >
> >       do: [:t5 | ex return: nil]
> >
> >Subtle difference in effect between resume: and return: (see the
> >respective method comments), and in any case I would suspect
> >FileDoesNotExistException of being non-resumable?
> 
> Well, FileStreamException implements
> 
> isResumable
>         "Determine whether an exception is resumable."
> 
>         ^true
> 
> which permits, I think, a single outer handler to fix things up for a variety of inner routines, e.g.:
> 
>         [
>                 self doLotsOfThings
>         ]
>                 on: FileDoesNotExistException
>                 do: [:ex |
>                         ex resume: (FileStream fileNamed: (self fixupFileName: ex fileName))
>                 ].
> 
> I also did a little test and
> 
>         do: [:t5 | nil]
>         do: [:t5 | ex resume: nil]
>         do: [:t5 | ex return: nil]
> 
> all do what is needed in this particular case, assuming a current VM.
> 
> Cheers,
> Bob





More information about the Squeak-dev mailing list