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

Julian Fitzell jfitzell at gmail.com
Wed Aug 31 22:13:05 UTC 2011


Nick and I sorted this out this evening. I assume he'll write up a
summary... ;)

On Tue, Aug 30, 2011 at 10:05 AM, Nick Ager <nick.ager at gmail.com> wrote:

> Hi,
>
> 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
> self'"
> GRPlatform current openDebuggerOn: ex ] ].
>
> "redirect the main page to the error location"
> self requestContext respond:
>  [ :response |
> 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
>
> Thanks,
>
> Nick
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110831/cda2a918/attachment.htm


More information about the seaside mailing list