FrozenCanuck / Ki

A Statechart Framework for SproutCore
http://frozencanuck.wordpress.com
Other
105 stars 7 forks source link

Exception management in statechart.sendEvent() #12

Closed rvalle closed 13 years ago

rvalle commented 13 years ago

HI!

statechart.sendEvent is silently handling all exceptions.

      } catch (ex) { /** Gobal the exception and move on */ }

Shouldn't this exceptions be thrown and available for: SC.ExceptionHandler.handleException() to process?

FrozenCanuck commented 13 years ago

Yes, good point. That bit of code you are referring to is a hold over from the older statechart framework. The intention back then was to handle any exception so that the state transition would finish and your app wouldn't crash. However, looking at it now, it really doesn't need to be there. This is something I'll address. Thanks for the notice.

rvalle commented 13 years ago

Yes, now the statechart does complete the transition without problem at all. The issue for me, was realizing that there was an exception happening.

May be in some cases either situation is the desired one. Perhaps, instead of throwing the exception and breaking the state-chart there could be a similar exceptionhandle inside the startechart (or if SC.ExceptionHandle.handleException() returns, the statechart can proceed as normal).

Something that could be cool is to give each state the possibility to handle the exception itself, that would make it possible to manage complex exception handle: such as implementing a "retry" state when a server cannot be reached or is too busy, (re)logon and continue where you was if the session has expired, etc.

FrozenCanuck commented 13 years ago

those are interesting ideas. I'll play around with it and see what works. But this is something that needs to be addressed in one form or another.

FrozenCanuck commented 13 years ago

this has been addressed. try-catch has been removed