open spec window to handle exception and pause execution

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

open spec window to handle exception and pause execution

Paul DeBruicker
Hi -

I have a subclass of ComposablePresenter (lets call it MyPresenter) that seems to work how I want.  When doing some processing I'd like to open MyPresenter  when an exception occurs and pass it the exception e.g.


[ [self testCondition] whileTrue:[ self doSomeStuff] ]
on: MyNotification
do:[:ex | self openMyPresenterWith: ex]

But that just results in lots of MyPresenter windows opening while the execution of the #whileTrue: loop runs its course.  


How do I pause the loop so I can use the MyPresenter window to modify and fix the condition that raised the MyNotification?  

The MyPresenter window just edits the contents of a couple Dictionaries so isn't too tricky but it isn't really as easy to do in a debugger as it is clicking a radio button and a "do it" button.  


Thanks
Reply | Threaded
Open this post in threaded view
|

Re: open spec window to handle exception and pause execution

Richard Sargent
Administrator
Paul, I'm going by memory and not Pharo specific.

I believe the default handling of the end of the exception block is implicitly equivalent to ex return: nil.

So, to get further handling of the exception, you need to #pass it or otherwise resignal it. Then the development environment will catch and handle the unhandled exception.


On Wed, Nov 20, 2019, 20:53 PAUL DEBRUICKER <[hidden email]> wrote:
Hi -

I have a subclass of ComposablePresenter (lets call it MyPresenter) that seems to work how I want.  When doing some processing I'd like to open MyPresenter  when an exception occurs and pass it the exception e.g.


[ [self testCondition] whileTrue:[ self doSomeStuff] ]
on: MyNotification
do:[:ex | self openMyPresenterWith: ex]

But that just results in lots of MyPresenter windows opening while the execution of the #whileTrue: loop runs its course. 


How do I pause the loop so I can use the MyPresenter window to modify and fix the condition that raised the MyNotification? 

The MyPresenter window just edits the contents of a couple Dictionaries so isn't too tricky but it isn't really as easy to do in a debugger as it is clicking a radio button and a "do it" button. 


Thanks
Reply | Threaded
Open this post in threaded view
|

Re: open spec window to handle exception and pause execution

Paul DeBruicker
Thanks Richard. That helped me figure it out.  I ended up doing:

[ [self testCondition] whileTrue:[ self doSomeStuff] ]
  on: MyNotification
  do:[:ex | |presenter |
       presenter:=MyPresenter forException: ex .
       presenter openWithSpec.
       Smalltalk ui theme runModal: presenter window]


Which does what I want


Richard Sargent wrote

> Paul, I'm going by memory and not Pharo specific.
>
> I believe the default handling of the end of the exception block is
> implicitly equivalent to ex return: nil.
>
> So, to get further handling of the exception, you need to #pass it or
> otherwise resignal it. Then the development environment will catch and
> handle the unhandled exception.
>
>
> On Wed, Nov 20, 2019, 20:53 PAUL DEBRUICKER &lt;

> pdebruic@

> &gt; wrote:
>
>> Hi -
>>
>> I have a subclass of ComposablePresenter (lets call it MyPresenter) that
>> seems to work how I want.  When doing some processing I'd like to open
>> MyPresenter  when an exception occurs and pass it the exception e.g.
>>
>>
>> [ [self testCondition] whileTrue:[ self doSomeStuff] ]
>> on: MyNotification
>> do:[:ex | self openMyPresenterWith: ex]
>>
>> But that just results in lots of MyPresenter windows opening while the
>> execution of the #whileTrue: loop runs its course.
>>
>>
>> How do I pause the loop so I can use the MyPresenter window to modify and
>> fix the condition that raised the MyNotification?
>>
>> The MyPresenter window just edits the contents of a couple Dictionaries
>> so
>> isn't too tricky but it isn't really as easy to do in a debugger as it is
>> clicking a radio button and a "do it" button.
>>
>>
>> Thanks
>>





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html