[VW] Using exception catching confuses Seaside?

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

[VW] Using exception catching confuses Seaside?

Martin J. Laubach-2
  In order to have a clean and tidy applications, I tried the
following in my WATask subclass:

        MyTask>>go
            [ "do application stuff" ]
                ensure: [ "close database connections" ]

  or

        MyTask>>go
            [ "do application stuff" ]
                on: Exception do: [ :ex | "whatever" ]


  Both confused the hell out of Seaside. The second one just kept
looping with the exception block catching a WACurrentSession. The
first one looped too but redirected the browser to itself.

  So I guess, #ensure/Exceptions and Seaside don't go together?

  Regards,

        mjl

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [VW] Using exception catching confuses Seaside?

Lukas Renggli
>         MyTask>>go
>             [ "do application stuff" ]
>                 on: Exception do: [ :ex | "whatever" ]

Short answer: Don't use Exception, but its subclass Error.

Long answer: You code also catches all the Notifications raised by
Seaside for different purposes and that are required to do the request
processing.

Solution: It is considered bad style to catch all kind of exceptions
within a single hander. Use #on:do: with more specific exceptions,
that works well with Seaside. If you need a specific error handler
customize a subclass of WAErrorHandler and use this one within your
application.

>         MyTask>>go
>             [ "do application stuff" ]
>                 ensure: [ "close database connections" ]

Short answer: Continuations don't go well together with #ensure: (ask Google).

Long answer: If you have different #call: statements within the
receiver of #ensure: the system cannot know when to evaluate the
argument of the #ensure: block. The user can always press the back
button of the browser and go back into the receiving block.

Solutions: Put your connection into a custom WASession class and close
it when the session is garbage collected. Or use a connection pool and
fetch a new connection for every request.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside