[Seaside] custom error handling results in: "Error: context not in self"

Nick Ager nick.ager at gmail.com
Tue Aug 30 09:05:07 UTC 2011


I'm using a hidden iframe in my file upload component. If an error occurs
during uploading, the error page is rendered in the hidden iframe - which
means I end up debugging by inspecting the http responses in the browsers
development tools. Not ideal so I thought I'd trap the error and present the
page myself. In the exception trap I send a script to the page which
redirects the parent window to the error page -
'parent.parent.window.location.replace(..error url..)' This works well apart
from when I click on the "debug" link, the debugger in the Pharo
reports: "Error: context not in self" and doesn't shows an unrelated (to the
original error) stack trace.

I've patched together my error handling code, by examining the error
handling filter in Seaside. I've had to add an accessor on
WASession>>#continuations, which probably indicates there is an easier way
to achieve my goal:

handleException: ex
| session requestContext key continuation renderContinuation |
requestContext := self requestContext.
session := requestContext session.
key := requestContext request fields at: session actionField.
continuation := session continuations at: key.
renderContinuation := continuation createRenderContinuation.
session presenter show: (WAWalkback current exception: ex) onAnswer:
[:answer |
answer ifTrue: [
self flag: #todo. "work out why I get the error: 'Error: context not in
GRPlatform current openDebuggerOn: ex ] ].

"redirect the main page to the error location"
self requestContext respond:
[ :response |
contentType: WAMimeType textHtml;
nextPutAll: (WARenderCanvas builder
fullDocument: true;
scriptGeneratorClass: JQScriptGenerator; "removes the onload from body"
render: [ :html |
html script: 'parent.parent.window.location.replace("', renderContinuation
registerForUrl  greaseString, '")' ] )]

I've a horrible feeling I'm missing an obvious, simpler solution


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110830/2c036518/attachment-0001.htm

More information about the seaside mailing list