« Return to Thread: Seaside Error Handler for emailing the error

Re: Seaside Error Handler for emailing the error

by Nevin Pratt :: Rate this Message:

Reply to Author | View in Thread

John Thornborrow wrote:

> For a simple solution, create a subclass of WAErrorHandler and
> override #handleError:
>
> EmailErrorHandler>>handleError: anError
>     SMTPClient
>         deliverMailFrom: 'foo@...'
>         to: 'bar@...'
>         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 'foo@...' 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: 'website@...'.
    str nextPut: Character cr.
    str nextPutAll: 'Subject: Stack Walkback
To: admin@...'.
    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: 'website@...'
        to: (Array with: 'admin@...')
        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 sales@....'.
    WACurrentSession value returnResponse: response
_______________________________________________
seaside mailing list
seaside@...
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 « Return to Thread: Seaside Error Handler for emailing the error