[Seaside] Error handlers and critical sections

Ron Teitelbaum Ron at USMedRec.com
Thu Sep 13 23:58:32 UTC 2007


Hi David,

I'm not sure I really understand your question.  There is a place in the
code for handling exceptions.  If you make your own subclass of WASession
then you can implement something like this: 

withErrorHandler: aBlock
	"override and extend the basic seaside exception handling"

	^[[super withErrorHandler: [aBlock
		on: USMRSDBObjectRegister do: [:ex | self registerObject: ex
object. ex resume]]]
		on: USMRSDBProxyReifier do: [:ex | self getObject: ex
object. ex resume]]
		on: USMRSDBCurrentCommitManager do: [:ex | ex resume: self
currentCommitManager].
	

The idea here is that the system will use the error handlers that are
included with seaside by calling super withErrorHandler: [

But then you can include your own Errors to handle.  Just subclass Exception
to create your own exception and name it what ever you want.  Then when you
want to handle a special case, raise the exception from your code.

For example in my code I could do this 
	
	aCommitManager := USMRSDBCurrentCommitManager signal.

This raises an exception unwinds the stack to this handler and then returns
the currentCommitManager.

It all works beautifully.  Hope that helps!!

Happy Coding,

Ron Teitelbaum
President / Principal Software Engineer
US Medical Record Specialists
Ron at USMedRec.com 




> -----Original Message-----
> From: C. David Shaffer
> 
> In continuing the process of answering myself...
> 
> I tried:
> 
> 
> [   [1/0] ensure: [Transcript show: 'got it.'; cr].
>     Transcript show: 'should not get here.'; cr ]
>         on: Error
>         do: [:ex | |signalContext handlerContext|
>             signalContext := ex instVarNamed: #signalContext.
>             handlerContext := ex instVarNamed: #handlerContext.
>             signalContext unwindTo: handlerContext.
>             self halt]
> 
> 
> Seems to work as expected ('got it' shows up in transcript before one
> quits the debugger).  So, I'm trying:
> 
> ProductionErrorHandler>>handleError: ex
>     |signalContext handlerContext|
>     signalContext := ex instVarNamed: #signalContext.
>     handlerContext := ex instVarNamed: #handlerContext.
>     signalContext unwindTo: handlerContext.
>      WACurrentSession value returnResponse: (WAResponse document: self
> document mimeType: 'text/html')
> 
> 
> for a bit to see how it goes.   If it seems right I'll embed it in
> exception and avoid all the instVarNamed: stuff.  This makes ensure: and
> critical: release their resources since there is no hope of re-entering
> their contexts.
> 
> David
> 
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list