bugsnag 1.1.0.0 → 1.1.0.1
raw patch · 4 files changed
+47/−40 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−3
- bugsnag.cabal +1/−1
- src/Network/Bugsnag/Exception.hs +32/−29
- test/Network/Bugsnag/ExceptionSpec.hs +8/−7
CHANGELOG.md view
@@ -1,8 +1,11 @@-## [_Unreleased_](https://github.com/pbrisbin/bugsnag-haskell/compare/bugsnag-v1.1.0.0...main)+## [_Unreleased_](https://github.com/pbrisbin/bugsnag-haskell/compare/bugsnag-v1.1.0.1...main) -- None+## [v1.1.0.1](https://github.com/pbrisbin/bugsnag-haskell/compare/bugsnag-v1.1.0.0...bugsnag-v1.1.0.1) -## [v1.0.1.0](https://github.com/pbrisbin/bugsnag-haskell/compare/bugsnag-v1.0.0.0...bugsnag-v1.1.0.0)+- Strip trailing newlines when constructing `Bugsnag.Exception` messages from+ `displayException` values.++## [v1.1.0.0](https://github.com/pbrisbin/bugsnag-haskell/compare/bugsnag-v1.0.0.0...bugsnag-v1.1.0.0) - New module: `Network.Bugsnag.MetaData`
bugsnag.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: bugsnag-version: 1.1.0.0+version: 1.1.0.1 license: MIT license-file: LICENSE maintainer: pbrisbin@gmail.com
src/Network/Bugsnag/Exception.hs view
@@ -56,9 +56,8 @@ -- | When a 'StringException' is thrown, we use its message and trace. bugsnagExceptionFromStringException :: StringException -> Exception bugsnagExceptionFromStringException (StringException message stack) =- defaultException+ (mkException $ Just $ T.pack message) { exception_errorClass = typeName @StringException- , exception_message = Just $ T.pack message , exception_stacktrace = callStackToStackFrames stack } @@ -69,9 +68,8 @@ bugsnagExceptionFromAnnotatedStringException :: AnnotatedException StringException -> Exception bugsnagExceptionFromAnnotatedStringException ae@AnnotatedException {exception = StringException message stringExceptionStack} =- defaultException+ (mkException $ Just $ T.pack message) { exception_errorClass = typeName @StringException- , exception_message = Just $ T.pack message , exception_stacktrace = maybe (callStackToStackFrames stringExceptionStack)@@ -88,35 +86,40 @@ bugsnagExceptionFromAnnotatedException ae = case annotatedExceptionCallStack ae of Just stack ->- defaultException+ (mkException $ Just $ T.pack $ displayException $ Annotated.exception ae) { exception_errorClass = exErrorClass $ Annotated.exception ae- , exception_message =- Just $ T.pack $ displayException $ Annotated.exception ae , exception_stacktrace = callStackToStackFrames stack } Nothing ->- let parseResult =- asum- [ fromException (Annotated.exception ae)- >>= (either (const Nothing) Just . parseErrorCall)- , either (const Nothing) Just $- parseStringException (Annotated.exception ae)- ]- in defaultException- { exception_errorClass =- exErrorClass $- Annotated.exception ae- , exception_message =- asum- [ mwsfMessage <$> parseResult- , Just $- T.pack $- displayException $- Annotated.exception- ae- ]- , exception_stacktrace = foldMap mwsfStackFrames parseResult- }+ let+ parseResult =+ asum+ [ fromException (Annotated.exception ae)+ >>= (either (const Nothing) Just . parseErrorCall)+ , either (const Nothing) Just $+ parseStringException (Annotated.exception ae)+ ]++ mmessage =+ asum+ [ mwsfMessage <$> parseResult+ , Just $+ T.pack $+ displayException $+ Annotated.exception+ ae+ ]+ in+ (mkException mmessage)+ { exception_errorClass = exErrorClass $ Annotated.exception ae+ , exception_stacktrace = foldMap mwsfStackFrames parseResult+ }++mkException :: Maybe Text -> Exception+mkException mmsg =+ defaultException+ { exception_message = T.dropWhileEnd (== '\n') <$> mmsg+ } -- | Unwrap the 'SomeException' newtype to get the actual underlying type name exErrorClass :: SomeException -> Text
test/Network/Bugsnag/ExceptionSpec.hs view
@@ -1,3 +1,5 @@+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}+ module Network.Bugsnag.ExceptionSpec ( spec ) where@@ -20,7 +22,7 @@ exception_message ex `shouldBe` Just "Something exploded" exception_stacktrace ex `shouldSatisfy` (not . null) - let frame = head $ exception_stacktrace ex+ let (frame : _) = exception_stacktrace ex stackFrame_file frame `shouldBe` "test/Examples.hs" stackFrame_lineNumber frame `shouldBe` 28 -- different versions of GHC disagree on where splices start@@ -47,7 +49,7 @@ exception_message ex `shouldBe` Just "empty list" exception_stacktrace ex `shouldSatisfy` ((== 3) . length) - let frame = head $ exception_stacktrace ex+ let (frame : _) = exception_stacktrace ex stackFrame_file frame `shouldBe` "test/Examples.hs" stackFrame_lineNumber frame `shouldBe` 36 stackFrame_columnNumber frame `shouldBe` Just 15@@ -64,7 +66,7 @@ exception_message ex `shouldBe` Just "empty list" exception_stacktrace ex `shouldSatisfy` ((== 3) . length) - let frame = head $ exception_stacktrace ex+ let (frame : _) = exception_stacktrace ex stackFrame_file frame `shouldBe` "test/Examples.hs" stackFrame_lineNumber frame `shouldBe` 43 stackFrame_columnNumber frame `shouldBe` Just 16@@ -79,11 +81,10 @@ let ex = bugsnagExceptionFromSomeException e exception_errorClass ex `shouldBe` "StringException" exception_message ex- `shouldBe` Just- "empty list\n and message with newlines\n\n"+ `shouldBe` Just "empty list\n and message with newlines" exception_stacktrace ex `shouldSatisfy` ((== 3) . length) - let frame = head $ exception_stacktrace ex+ let (frame : _) = exception_stacktrace ex stackFrame_file frame `shouldBe` "test/Examples.hs" stackFrame_lineNumber frame `shouldBe` 50 stackFrame_columnNumber frame `shouldBe` Just 17@@ -103,7 +104,7 @@ exception_message ex `shouldBe` Just "empty list" exception_stacktrace ex `shouldSatisfy` ((== 2) . length) - let frame = head $ exception_stacktrace ex+ let (frame : _) = exception_stacktrace ex stackFrame_file frame `shouldBe` "test/Examples.hs" stackFrame_lineNumber frame `shouldBe` 53 stackFrame_columnNumber frame `shouldBe` Just 27