Seaside Error Handler for emailing the error

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

Seaside Error Handler for emailing the error

Nevin Pratt
Old versions of Seaside had an error handler that could email an
administrator the stack trace if an error occured.  I don't see that
option in the newer Seaside versions.  Am I overlooking something?

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

Re: Seaside Error Handler for emailing the error

Nevin Pratt
Nevin Pratt wrote:
> Old versions of Seaside had an error handler that could email an
> administrator the stack trace if an error occured.  I don't see that
> option in the newer Seaside versions.  Am I overlooking something?
>
> Nevin

To be more specific, old versions of Seaside had WAEmailErrorPage, which
would email the error to whomever I chose.

New Seaside versions do not have any such functionality (that I can see).

Has anybody created it?

Nevin

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

Re: Seaside Error Handler for emailing the error

cedreek
Hi
>
> > Old versions of Seaside had an error handler that could email an
> administrator the stack trace if an error occured.  I don't see that option
> in the newer Seaside versions.  Am I overlooking something?
> >
I think they removed that because of platform specific code.
Maybe, just subclass WAWalkbackErrorHandler and probably ovveride:

open: anException
        | answer |
        answer := WARenderLoop new
                call: (WAWalkback exception: anException)
                withToolFrame: false.
        answer ifTrue: [ SeasidePlatformSupport openDebuggerOn: anException ]

instead of
SeasidePlatformSupport openDebuggerOn: anException

somethink like:

|mailText|
mailText := SeasidePlatformSupport  walkbackStringsFor: anException.
SeasidePlatformSupport  deliverMailFrom: fromAddress to: recipientList
text: mailText.

You also have to chage the answer so as not to display to a proper
error page then probably a redirect on home...
WARenderLoop new
                call: (YouErrorComponent new)   "that do a redirect maybe"
                withToolFrame: false.   "not sure of call:withToolFrame:   maybe just call:"

This is not testet, just a guess...  I'll try later maybe

HTH

Cédrick

>
>  To be more specific, old versions of Seaside had WAEmailErrorPage, which
> would email the error to whomever I chose.
>
>  New Seaside versions do not have any such functionality (that I can see).
>
>  Has anybody created it?
>
>
>
>  Nevin
>
>  _______________________________________________
>  seaside mailing list
>  [hidden email]
>  http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

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

Re: Seaside Error Handler for emailing the error

cedreek
another try... this one works but need some tuning.

open: anException
        |maillerait sender target|
        sender := 'seaside image'.
        target := '[hidden email]'.
        mailText :=
'From: ', sender ,'
To: ', target , '
Subject: error in your seaside app
'.
        (SeasidePlatformSupport  walkbackStringsFor: anException)
                do: [ :each | mailText := (mailText , each) ]
                separatedBy: [ String crlf ].
        SeasidePlatformSupport  deliverMailFrom: sender to: #(target) text: mailText .

        WARenderLoop new session redirectWithMessage: 'error' delay: 2.
"others,   are there better ways to do that?  "


Cédrick

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

Re: Seaside Error Handler for emailing the error

cedreek
oups, still errors...

YourErrorHandler>>open: anException
        |mailText sender target|
        sender := '[hidden email]'.
        target := #('[hidden email]').
        mailText :=
'From: ', sender ,'
To: ', target first , '
Subject: error in your seaside app
'.
        (SeasidePlatformSupport  walkbackStringsFor: anException)
                do: [ :each | mailText := (mailText , each) ]
                separatedBy: [ String cr].
       
        SeasidePlatformSupport  deliverMailFrom: sender to: target
text: mailText .

        WARenderLoop new session redirectWithMessage: 'error' delay: 2.


I cannot display the carriage return properly, but otherwise, it seems ok

Cédrick

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

Re: Seaside Error Handler for emailing the error

Philippe Marschall
2008/5/3, cdrick <[hidden email]>:

> oups, still errors...
>
>  YourErrorHandler>>open: anException
>         |mailText sender target|
>         sender := '[hidden email]'.
>         target := #('[hidden email]').
>         mailText :=
>  'From: ', sender ,'
>  To: ', target first , '
>
> Subject: error in your seaside app
>  '.
>         (SeasidePlatformSupport  walkbackStringsFor: anException)
>                 do: [ :each | mailText := (mailText , each) ]
>
>                 separatedBy: [ String cr].
>
>
>         SeasidePlatformSupport  deliverMailFrom: sender to: target
>  text: mailText .

You'll want String class >> #streamContents:. Note you need two crs
after the subject. I know this is PHP-style, that's why there is:
http://code.google.com/p/seaside/issues/detail?id=41

You can also have a look at Debugger >> #mailOutBugReport

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

Re: Seaside Error Handler for emailing the error

johnmci
In reply to this post by Nevin Pratt
Nevin, I'm reminded of a old solution of 10 years back where someone I  
knew in the early days of Gemstone would stuff the VW stack context  
into Gemstone, then email the developer.
The developer then could take load the context and then have an image  
that matched what happened when the error occurred, which greatly  
assisted debugging.

I note if you are using squeak, the stack dump routine doesn't print a  
sufficient number of stack frames, or data. For Sophie we had to  
adjust things by as much as a factor of 10
to get enough information that is mailed by request to our developer  
site when an uncaught exception occurs.

On May 2, 2008, at 6:52 PM, Nevin Pratt wrote:

> Old versions of Seaside had an error handler that could email an  
> administrator the stack trace if an error occured.  I don't see that  
> option in the newer Seaside versions.  Am I overlooking something?
>
> Nevin
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================


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

Re: Seaside Error Handler for emailing the error

John Thornborrow
In reply to this post by Nevin Pratt
For a simple solution, create a subclass of WAErrorHandler and override
#handleError:

EmailErrorHandler>>handleError: anError
        SMTPClient
                deliverMailFrom: '[hidden email]'
                to: '[hidden email]'
                text: 'Subject: Seaside error - ', anError messageText,'

The was an error!

', anError stackString: 100


Nevin Pratt wrote:

> Old versions of Seaside had an error handler that could email an
> administrator the stack trace if an error occured.  I don't see that
> option in the newer Seaside versions.  Am I overlooking something?
>
> Nevin
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

--
John Thornborrow
http://www.pinesoft.co.uk


******************************************************************************************************************************************
This email is from Pinesoft Limited. Its contents are confidential to the intended recipient(s) at the email address(es) to which it has been addressed. It may not be disclosed to or used by anyone other than the addressee(s), nor may it be copied in anyway. If received in error, please contact the sender, then delete it from your system. Although this email and attachments are believed to be free of virus, or any other defect which might affect any computer or IT system into which they are received and opened, it is the responsibility of the recipient to ensure that they are virus free and no responsibility is accepted by Pinesoft for any loss or damage arising in any way from receipt or use thereof. *******************************************************************************************************************************************


Pinesoft Limited are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside Error Handler for emailing the error

Nevin Pratt
John Thornborrow wrote:

> For a simple solution, create a subclass of WAErrorHandler and
> override #handleError:
>
> EmailErrorHandler>>handleError: anError
>     SMTPClient
>         deliverMailFrom: '[hidden email]'
>         to: '[hidden email]'
>         text: 'Subject: Seaside error - ', anError messageText,'
>
> The was an error!
>
> ', anError stackString: 100
>
>


Yep, that's what I did.  This is what I have (except with real email
addresses instead of the '[hidden email]' stuff).  I also currently have
the 'self halt' in the error handler (as shown below), but might replace
it with 'self resume' or something else later.

Nevin

************************

handleError: anError
    | str response |
    [str := ReadWriteStream with: String new.
    str nextPutAll: 'Date: '.
    str nextPutAll: MailMessage dateStampNow.
    str nextPut: Character cr.
    str nextPutAll: 'From: '.
    str nextPutAll: '[hidden email]'.
    str nextPut: Character cr.
    str nextPutAll: 'Subject: Stack Walkback
To: [hidden email]'.
    str nextPut: Character cr.
    str nextPut: Character cr.
    str nextPutAll: anError printString.
    str nextPut: Character cr.
    str nextPut: Character cr.
    (anError signalerContext sender stackOfSize: 15)
        do: [:ea |
            ea printDetails: str.
            str nextPut: Character cr.
            str nextPutAll: '--------------------------------------'.
            str nextPut: Character cr].
    str nextPut: Character linefeed.
    SeasidePlatformSupport
        deliverMailFrom: '[hidden email]'
        to: (Array with: '[hidden email]')
        text: str contents]
        on: Error
        do: [:ex | self halt].
    response := WAResponse new.
    response nextPutAll: '<h1>Error</h1> There has been an internal
error.  The system administrator has been notified.<br><br>If you have
questions or concerns, you can contact our Foo Bar office toll free at:
877-6FOOBAR<br>or email us at [hidden email].'.
    WACurrentSession value returnResponse: response
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside