Safe Haskell | None |
---|---|
Language | Haskell2010 |
snap-error-collector
extends a Snap
application with the ability to monitor
requests for uncaught exceptions. All routes are wrapped with an exception
handler, and exceptions are queued (and optionally filtered). Periodically,
the exception queue is flushed via an IO
computation - you can use this
to send emails, notify yourself on Twitter, increment counters, etc.
Example:
import Snap.ErrorCollector initApp ::Initializer
MyApp MyApp initApp = do ...collectErrors
ErrorCollectorConfig
{ecFlush
= emailOpsTeam ,ecFlushInterval
= 60000000 ,ecFilter
=const
True
,ecUpperBound
= 1000 } emailOpsTeam ::UTCTime
->Seq
LoggedException
->Int
->IO
'()' emailOpsTeam = ...
- collectErrors :: ErrorCollectorConfig -> Initializer b v ()
- data LoggedException = LoggedException {
- leException :: !SomeException
- leLoggedAt :: !UTCTime
- leRequest :: !Request
- data ErrorCollectorConfig = ErrorCollectorConfig {
- ecFlush :: !(UTCTime -> Seq LoggedException -> Int -> IO ())
- ecFlushInterval :: !Int
- ecFilter :: !(SomeException -> Bool)
- ecExceptionUpperBound :: !Int
- basicConfig :: (UTCTime -> Seq LoggedException -> Int -> IO ()) -> ErrorCollectorConfig
Documentation
collectErrors :: ErrorCollectorConfig -> Initializer b v () Source
Wrap a Snap
website to collect errors.
data LoggedException Source
An exception logged by snap-error-collector
, tagged with the request that
caused the exception, and the time the exception occured.
LoggedException | |
|
data ErrorCollectorConfig Source
How snap-error-collector
should run.
ErrorCollectorConfig | |
|
basicConfig :: (UTCTime -> Seq LoggedException -> Int -> IO ()) -> ErrorCollectorConfig Source
A convenient constructor for ErrorCollectorConfig
that collects up to
100 exceptions and flushes the queue every minute. You have to supply the
IO
action to run when the queue is flushed.