[Pharo-project] [squeak-dev] My solution to handling errors in system-critical processes

Igor Stasenko siguctua at gmail.com
Fri May 20 20:15:18 EDT 2011


Another application to elegantly solve well known problem:
 - spawning debugger windows in the loop, which effectively kills your
image, because you
cannot close those windows at the same rate they appear.

So, consider a following :

100 timesRepeat: [
  [ 1/0 ] on: Error fork: [:ex | ex pass ]
]

this is what you usually get, if you are not careful or not doing self
haltOnce etc..
Which actually makes debugging UI a hellishly tedious and hard task.
Now what we can do instead?

| sema |

sema := Semaphore forMutualExclusion.

100 timesRepeat: [
  [ 1/0 ] on: Error fork: [:ex | sema critical: [ ex pass ] ]
]

now, you will see only a single window opened at one point of time.
And once you deal with error, if there's another one,
it will open second one and so on.. But not all of them at once.

And later, if we are not happy with this, we could add a feature to
'Abandon same class of errors' , i.e.
terminate forks with all errors which originated from same method. In
that way, you can deal with error once, and kill the rest which
otherwise will annoy you to death.


-- 
Best regards,
Igor Stasenko AKA sig.




More information about the Pharo-dev mailing list