[Seaside-dev] exception handler instance creation
Julian Fitzell
jfitzell at gmail.com
Mon Dec 29 20:12:33 UTC 2008
I started writing some docs on the new exception handler interface. In
doing so, I realized I hated the method name #exceptionToCatch so I
changed that and then remembered that Lukas was asking for the
exception handlers to implement #handles: and #, so that they can be
used in place of an ExceptionSet as defined in the ANSI spec. So I did
this too.
This raised again the question of when an instance of our exception
handlers should be created. If you look at the current implementation
of #handleExceptionsDuring:context:, you will see that an instance is
not actually created until an exception that this class handles is
signaled. This requires a temporary variable and means that the
instance does not have a chance to indicate whether it wants to handle
the exception or not (whether they is a required feature or not is
perhaps debatable... I dunno).
The only reason I did this was to avoid the overhead of creating the
instance when we don't need it but I'm wondering if this was a
premature optimization and the implementation would be simpler if I
didn't do it. #handleExceptionsDuring:context: would just become:
#handleExceptionsDuring: aBlock context: aRequestContext
^ (self context: aRequestContext) handleExceptionsDuring: aBlock
And on the instance side we would have:
#handleExceptionsDuring: aBlock
^ aBlock
on: self
do: [ :exception |
[ self handleException: exception ]
on: Error
do: [ :error | self internalError: error ] ]
No temporary variable, instances can choose whether to handle
exceptions if they want to, no risk of being unable to create an error
handler when reporting an internal error.
Am I right that this seems like the better option?
Julian
More information about the seaside-dev
mailing list