[Seaside] Ajax and error management
johan at inceptive.be
Sat May 14 18:19:30 UTC 2011
Exceptions in Seaside are handled by an instance of (a subclass of) WAExceptionHandler. Setting the exception handler is part of the application configuration.
For development, Seaside provides you with exception handlers (e.g. WAWalkbackErrorHandler) that return an exception page and that can open a debugger on the server-side (or they put a continuation on the objectlog in GLASS).
To change the server-side behavior. I think you can find your way by looking at the implementation of the existing handlers.
To give you yet another example, here is the principal code of an error handler we are using in production code. In combination with a global ajax error handler, it makes sure that a decent error message is put on the screen (in a kind of dialog window) whenever an error occurred server-side in an ajax callback.
[self logErrorToDisk: anException]
ensure: [self requestContext respond: [ :response |
contentType: WAMimeType textHtml;
nextPutAll: (self rendererClass builder
rootBlock: [ :root | root title: anException description ];
render: [:html | html render:(NPProductionErrorDialog exception: anException)])]]
Hope this gets you on your way!
On 13 May 2011, at 22:50, Thierry Thelliez wrote:
> While I successfully created my first JQuery modal dialog, I
> encountered two issues regarding exception management:
> ===1=== At one point I had a bug in my code (I know, this never
> happens ;-). The component rendering the dialog did not seem to
> respond to user input. Inspecting with Firebug, I found that the
> server (GLASS) was returning a 505. But the debugger (Seaside
> Walkback html page) was not displayed. Now, I understand that this is
> do you do that in Seaside?
> In other words, the code below works. But do you have any code
> example on how to manage exception should my 'myComponent' not behave?
> html div
> id: (html nextId);
> script: (html jQuery new dialog
> html: myComponent;
> title: 'Title';
> height: 180;
> width: 420;
> resizable: false;
> autoOpen: false;
> modal: true).
> html anchor
> url: '#';
> onClick: (( html jQuery id: html lastId) dialog open );
> with: 'Test'
> ===2=== Likewise, I got a 403 when leaving my first calling page
> opened for a while. I mean that attempting to open the above dialog
> does not work anymore after a time that I think is the session
> expiration. I guess that the link under 'Test' calls
> that is expired. (BTW, I am using Seaside 3.0 and GLASS).
> Again, I would like to be able to intercept such exception/error and
> provide something more user friendly. Right now the dialog opens a
> blank dialog.
> seaside mailing list
> seaside at lists.squeakfoundation.org
More information about the seaside