[Seaside] Seaside Error Handler for emailing the error
Nevin Pratt
nevin at bountifulbaby.com
Wed May 7 14:15:16 UTC 2008
John Thornborrow wrote:
> For a simple solution, create a subclass of WAErrorHandler and
> override #handleError:
>
> EmailErrorHandler>>handleError: anError
> SMTPClient
> deliverMailFrom: 'foo at bar.com'
> to: 'bar at foo.com'
> 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 at bar.com' 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 at bar.com'.
str nextPut: Character cr.
str nextPutAll: 'Subject: Stack Walkback
To: admin at bar.com'.
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 at bar.com'
to: (Array with: 'admin at bar.com')
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 at bar.com.'.
WACurrentSession value returnResponse: response
More information about the seaside
mailing list