Hi Antony,
The reason this doesn't work:
"
[ #(1 2) do: [:i | self error: 'test'] ] on: Error do: [ :ex |
ex
inspect ].
will show that ex initialContext sender is nil.
"
Is because when the error handling block opens an inspector and then
just continues evaluating the handler block. Since there are no more
statements at the end of the block, it is as if there would have been:
[ #(1 2) do: [:i | self error: 'test'] ]
on: Error
do: [ :ex |
ex inspect.
ex return
].
It's the 'ex return' that causes the stack to be curtailed.
The same applies to the example with the 'fork' you've given.
-----Original Message-----
From:
[hidden email] [mailto:
[hidden email]] On
Behalf Of Antony Blakey
Sent: woensdag 11 juli 2007 12:29
To: Mark Plas
Cc: VW-Development List; VWNC; Michael Lucas-Smith
Subject: Re: Exception stack curtailment (in HttpServerStreams)
And that works for me ... what's misleading though is that this:
[ #(1 2) do: [:i | self error: 'test'] ] on: Error do: [ :ex | ex
inspect ].
will show that ex initialContext sender is nil.
And the reason I was exploring this was that code like this:
[self recordWalkback: (self getWalkbackFrom: exception)] fork.
which is in HttpServerStreams, was also only dumping the top of the
stack, even thought it also walks the context sender chain.
The fact that your code works makes me suspect that crossing a
process boundary may be responsible for clearing the sender on each
context. I'm presuming that the inspector is in a different process.
For example, this:
[ #(1 2) do: [:i | self error: 'test'] ]
on: Error
do: [:ex |
[ | cnt startContext str |
startContext := ex initialContext.
cnt := 0.
str := WriteStream on: String new.
[startContext notNil and: [cnt < 10]] whileTrue:
[startContext printOn: str. str cr.
startContext := startContext sender.
cnt := cnt + 1].
str contents inspect
] fork
]
doesn't work, whereas it does without the fork.
In any case, mystery solved
On 11/07/2007, at 7:43 PM, Mark Plas wrote:
> [#(1 2) do: [:i | self error: 'test']]
> on: Error
> do: [:ex |
> | cnt startContext str |
> startContext := ex initialContext.
> cnt := 0.
> str := WriteStream on: String new.
> [startContext notNil and: [cnt < 10]] whileTrue:
> [startContext printOn: str. str cr.
> startContext := startContext sender.
> cnt := cnt + 1].
> str contents ]
Antony Blakey
-------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787
Did you hear about the Buddhist who refused Novocain during a root
canal?
His goal: transcend dental medication.