File tree 13 files changed +151
-5
lines changed
13 files changed +151
-5
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ packages:
2
2
rollbar-cli/
3
3
rollbar-client/
4
4
rollbar-wai/
5
+ rollbar-yesod/
Original file line number Diff line number Diff line change @@ -19,12 +19,17 @@ import Data.Aeson
19
19
import Network.HTTP.Types (renderQuery )
20
20
import Rollbar.Client
21
21
22
- rollbarOnException :: Settings -> Maybe W. Request -> SomeException -> IO ()
23
- rollbarOnException settings mreq ex = void $ forkIO $
22
+ rollbarOnException
23
+ :: MonadIO m
24
+ => Settings
25
+ -> Maybe W. Request
26
+ -> SomeException
27
+ -> m ()
28
+ rollbarOnException settings mreq ex = void $ liftIO $ forkIO $
24
29
runRollbar settings $ do
25
- itemData <- mkData $ PayloadTrace $ Trace [] $ mkException ex
30
+ idata <- mkData $ PayloadTrace $ Trace [] $ mkException ex
26
31
mdreq <- mapM mkRequest mreq
27
- void $ createItem $ Item itemData { dataRequest = mdreq }
32
+ void $ createItem $ Item idata { dataRequest = mdreq }
28
33
29
34
mkRequest :: MonadIO m => W. Request -> m Request
30
35
mkRequest req = liftIO $ do
@@ -38,7 +43,7 @@ mkRequest req = liftIO $ do
38
43
, requestGet = HM. fromList $ fmap toQuery $ W. queryString req
39
44
, requestQueryStrings = T. decodeUtf8 $ renderQuery False $ W. queryString req
40
45
, requestPost = HM. fromList $ fmap toParam params
41
- , requestBody = mempty
46
+ , requestBody = " "
42
47
, requestUserIp = " "
43
48
}
44
49
where
Original file line number Diff line number Diff line change
1
+ .stack-work /
2
+ * ~
Original file line number Diff line number Diff line change
1
+ # Changelog for rollbar-yesod
2
+
3
+ ## Unreleased changes
Original file line number Diff line number Diff line change
1
+ ../LICENSE
Original file line number Diff line number Diff line change
1
+ # rollbar-yesod
Original file line number Diff line number Diff line change
1
+ import Distribution.Simple
2
+ main = defaultMain
Original file line number Diff line number Diff line change
1
+ name : rollbar-yesod
2
+ version : 0.1.0
3
+ github : " stackbuilders/rollbar-haskell"
4
+ license : MIT
5
+ author : " Stack Builders Inc."
6
+ maintainer :
" Sebastián Estrella <[email protected] >"
7
+ copyright : " 2020 Stack Builders Inc."
8
+ tested-with : GHC ==8.6.5, GHC ==8.8.4, GHC ==8.10.2
9
+
10
+ extra-source-files :
11
+ - README.md
12
+ - ChangeLog.md
13
+
14
+ # Metadata used when publishing your package
15
+ # synopsis: Short description of your package
16
+ # category: Web
17
+
18
+ description :
19
+ Please see the README on GitHub at
20
+ <https://github.com/stackbuilders/rollbar-haskell/tree/master/rollbar-yesod>
21
+
22
+ dependencies :
23
+ - base >= 4.12 && < 5
24
+
25
+ library :
26
+ source-dirs : src
27
+ dependencies :
28
+ - exceptions
29
+ - rollbar-client
30
+ - rollbar-wai
31
+ - yesod-core
32
+
33
+ tests :
34
+ rollbar-yesod-test :
35
+ main : Spec.hs
36
+ source-dirs : test
37
+ ghc-options :
38
+ - -threaded
39
+ - -rtsopts
40
+ - -with-rtsopts=-N
41
+ dependencies :
42
+ - rollbar-yesod
Original file line number Diff line number Diff line change
1
+ cabal-version : 1.12
2
+
3
+ -- This file has been generated from package.yaml by hpack version 0.33.0.
4
+ --
5
+ -- see: https://github.com/sol/hpack
6
+ --
7
+ -- hash: 70eae7a982eea17f10d248ef08146e18198494e0bbd1de8bdc6040d9ed7396fd
8
+
9
+ name : rollbar-yesod
10
+ version : 0.1.0
11
+ description : Please see the README on GitHub at <https://github.com/stackbuilders/rollbar-haskell/tree/master/rollbar-yesod>
12
+ homepage : https://github.com/stackbuilders/rollbar-haskell#readme
13
+ bug-reports : https://github.com/stackbuilders/rollbar-haskell/issues
14
+ author : Stack Builders Inc.
15
+ maintainer : Sebastián Estrella <
[email protected] >
16
+ copyright : 2020 Stack Builders Inc.
17
+ license : MIT
18
+ license-file : LICENSE
19
+ tested-with : GHC == 8.6.5 , GHC == 8.8.4 , GHC == 8.10.2
20
+ build-type : Simple
21
+ extra-source-files :
22
+ README.md
23
+ ChangeLog.md
24
+
25
+ source-repository head
26
+ type : git
27
+ location : https://github.com/stackbuilders/rollbar-haskell
28
+
29
+ library
30
+ exposed-modules :
31
+ Rollbar.Yesod
32
+ other-modules :
33
+ Paths_rollbar_yesod
34
+ hs-source-dirs :
35
+ src
36
+ build-depends :
37
+ base >= 4.12 && < 5
38
+ , exceptions
39
+ , rollbar-client
40
+ , rollbar-wai
41
+ , yesod-core
42
+ default-language : Haskell2010
43
+
44
+ test-suite rollbar-yesod-test
45
+ type : exitcode-stdio-1.0
46
+ main-is : Spec.hs
47
+ other-modules :
48
+ Paths_rollbar_yesod
49
+ hs-source-dirs :
50
+ test
51
+ ghc-options : -threaded -rtsopts -with-rtsopts=-N
52
+ build-depends :
53
+ base >= 4.12 && < 5
54
+ , rollbar-yesod
55
+ default-language : Haskell2010
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE FlexibleContexts #-}
2
+
3
+ module Rollbar.Yesod
4
+ ( rollbarYesodMiddleware
5
+ ) where
6
+
7
+ import Control.Monad
8
+ import Control.Monad.Catch
9
+ import Rollbar.Client
10
+ import Rollbar.Wai (rollbarOnException )
11
+ import Yesod.Core
12
+ import Yesod.Core.Types (HandlerContents )
13
+
14
+ rollbarYesodMiddleware
15
+ :: MonadCatch (HandlerFor site )
16
+ => Settings
17
+ -> HandlerFor site res
18
+ -> HandlerFor site res
19
+ rollbarYesodMiddleware settings handler = handler `catch` \ ex -> do
20
+ unless (isHandlerContents ex) $ do
21
+ req <- waiRequest
22
+ rollbarOnException settings (Just req) ex
23
+
24
+ throwM ex
25
+
26
+ isHandlerContents :: SomeException -> Bool
27
+ isHandlerContents = maybe False bar . fromException
28
+ where
29
+ bar :: HandlerContents -> Bool
30
+ bar = const True
Original file line number Diff line number Diff line change
1
+ main :: IO ()
2
+ main = putStrLn " Test suite not yet implemented"
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ packages:
4
4
- ./rollbar-cli
5
5
- ./rollbar-client
6
6
- ./rollbar-wai
7
+ - ./rollbar-yesod
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ packages:
4
4
- ./rollbar-cli
5
5
- ./rollbar-client
6
6
- ./rollbar-wai
7
+ - ./rollbar-yesod
You can’t perform that action at this time.
0 commit comments