packages feed

bugsnag-yesod 1.0.1.0 → 1.0.1.3

raw patch · 4 files changed

+45/−38 lines, 4 filesdep ~annotated-exceptiondep ~bugsnagdep ~bugsnag-waiPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: annotated-exception, bugsnag, bugsnag-wai, unliftio, wai, warp, yesod-core

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,6 +1,10 @@-## [_Unreleased_](https://github.com/pbrisbin/bugsnag-haskell/compare/bugsnag-yesod-v1.0.1.0...main)+For changes after `v1.0.1.0` see [Releases][releases] on Codeberg. -- None+[releases]: https://codeberg.org/pbrisbin/bugsnag-haskell/releases?q=bugsnag-yesod-v++---++Previous releases:  ## [v1.0.1.0](https://github.com/pbrisbin/bugsnag-haskell/compare/bugsnag-yesod-v1.0.0.1...v1.0.1.0) 
bugsnag-yesod.cabal view
@@ -1,11 +1,11 @@ cabal-version:   1.18 name:            bugsnag-yesod-version:         1.0.1.0+version:         1.0.1.3 license:         MIT license-file:    LICENSE maintainer:      pbrisbin@gmail.com author:          Patrick Brisbin-homepage:        https://github.com/pbrisbin/bugsnag-haskell#readme+homepage:        https://codeberg.org/pbrisbin/bugsnag-haskell#readme synopsis:        Yesod integration for Bugsnag error reporting for Haskell description:     Please see README.md category:        Web@@ -33,13 +33,13 @@         TypeApplications TypeFamilies      build-depends:-        annotated-exception >=0.2.0.2,+        annotated-exception >=0.2.0.4,         base >=4.11.0 && <5,-        bugsnag >=1.0.0.1,-        bugsnag-wai >=1.0.0.1,-        unliftio >=0.2.9.0,-        wai >=3.2.1.2,-        yesod-core >=1.6.9+        bugsnag >=1.0.0.0,+        bugsnag-wai >=1.0.0.0,+        unliftio >=0.2.25.0,+        wai >=3.2.3,+        yesod-core >=1.6.24.2  executable example-yesod     main-is:            Main.hs@@ -57,9 +57,9 @@      build-depends:         base >=4.11.0 && <5,-        bugsnag >=1.0.0.1,+        bugsnag >=1.0.0.0,         bugsnag-yesod,-        warp >=3.2.25,+        warp >=3.3.23,         yesod-core >1.6      if !flag(examples)
example/Main.hs view
@@ -13,20 +13,20 @@ import Network.Wai.Handler.Warp (run) import Yesod.Core -newtype App = App { appBugsnag :: Settings }+newtype App = App {appBugsnag :: Settings} mkYesod "App" [parseRoutes|/ RootR GET|]  getRootR :: Handler Html getRootR = error "Boom"  instance Yesod App where-    defaultLayout _widget = withUrlRenderer [hamlet|<html>|]-    yesodMiddleware =-        bugsnagYesodMiddleware appBugsnag . defaultYesodMiddleware+  defaultLayout _widget = withUrlRenderer [hamlet|<html>|]+  yesodMiddleware =+    bugsnagYesodMiddleware appBugsnag . defaultYesodMiddleware  main :: IO () main = do-    let appBugsnag = defaultSettings "BUGSNAG_API_KEY"+  let appBugsnag = defaultSettings "BUGSNAG_API_KEY" -    -- N.B. You should also consider setting Warp's onException-    run 3000 =<< toWaiApp App { .. }+  -- N.B. You should also consider setting Warp's onException+  run 3000 =<< toWaiApp App {..}
src/Network/Bugsnag/Yesod.hs view
@@ -9,11 +9,10 @@ -- The main downside to this middleware is that short-circuit responses also -- come through the middleware as exceptions, and must be filtered. Unless of -- course you want to notify Bugsnag of 404s and such.--- module Network.Bugsnag.Yesod-    ( bugsnagYesodMiddleware-    , bugsnagYesodMiddlewareWith-    ) where+  ( bugsnagYesodMiddleware+  , bugsnagYesodMiddlewareWith+  ) where  import Prelude @@ -26,32 +25,36 @@ import Network.Bugsnag.Wai import qualified Network.Wai as Wai import UnliftIO.Exception-    (Exception, SomeException, fromException, withException)+  ( Exception+  , SomeException+  , fromException+  , withException+  ) import Yesod.Core (forkHandler, getsYesod, waiRequest) import Yesod.Core.Types (HandlerContents, HandlerFor)  bugsnagYesodMiddleware-    :: (app -> Settings) -> HandlerFor app a -> HandlerFor app a+  :: (app -> Settings) -> HandlerFor app a -> HandlerFor app a bugsnagYesodMiddleware = bugsnagYesodMiddlewareWith updateEventFromWaiRequest  bugsnagYesodMiddlewareWith-    :: (Wai.Request -> BeforeNotify)-    -> (app -> Settings)-    -> HandlerFor app a-    -> HandlerFor app a+  :: (Wai.Request -> BeforeNotify)+  -> (app -> Settings)+  -> HandlerFor app a+  -> HandlerFor app a bugsnagYesodMiddlewareWith mkBeforeNotify getSettings handler = do-    settings <- getsYesod getSettings-    request <- waiRequest+  settings <- getsYesod getSettings+  request <- waiRequest -    handler `withException` \ex ->-        unless (isHandlerContents ex)-            $ forkHandler (const $ pure ())-            $ liftIO-            $ notifyBugsnagWith (mkBeforeNotify request) settings ex+  handler `withException` \ex ->+    unless (isHandlerContents ex) $+      forkHandler (const $ pure ()) $+        liftIO $+          notifyBugsnagWith (mkBeforeNotify request) settings ex  isHandlerContents :: SomeException -> Bool isHandlerContents ex =-    is @HandlerContents ex || is @(AnnotatedException HandlerContents) ex+  is @HandlerContents ex || is @(AnnotatedException HandlerContents) ex -is :: forall e . Exception e => SomeException -> Bool+is :: forall e. Exception e => SomeException -> Bool is = isJust . fromException @e