annotated-exception 0.3.0.0 → 0.3.0.1
raw patch · 4 files changed
+43/−4 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +7/−0
- annotated-exception.cabal +1/−1
- src/Control/Exception/Annotated.hs +9/−1
- test/Control/Exception/AnnotatedSpec.hs +26/−2
ChangeLog.md view
@@ -1,5 +1,12 @@ # Changelog for `annotated-exception` +## 0.3.0.1++- [#31](https://github.com/parsonsmatt/annotated-exception/pull/31)+ - The `Show` instance for `AnnotatedException` attempts to peek into the+ `SomeException` to provide a more useful exception type. Also gives the+ output of `show`.+ ## 0.3.0.0 - [#30](https://github.com/parsonsmatt/annotated-exception/pull/30)
annotated-exception.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: annotated-exception-version: 0.3.0.0+version: 0.3.0.1 synopsis: Exceptions, with checkpoints and context. description: Please see the README on Github at <https://github.com/parsonsmatt/annotated-exception#readme> category: Control
src/Control/Exception/Annotated.hs view
@@ -125,13 +125,21 @@ displayException (AnnotatedException {..}) = unlines [ "! AnnotatedException !"- , "Underlying exception type: " <> show (typeOf exception)+ , "Underlying exception type: " <> show exceptionType+ , ""+ , "show:"+ , "\t" <> show exception+ , "" , "displayException:" , "\t" <> Safe.displayException exception ] <> annotationsMessage <> callStackMessage where+ exceptionType =+ case Safe.toException exception of+ SomeException innerException ->+ typeOf innerException (callStacks, otherAnnotations) = tryAnnotations @CallStack annotations callStackMessage = case listToMaybe callStacks of
test/Control/Exception/AnnotatedSpec.hs view
@@ -14,10 +14,10 @@ import Control.Exception.Annotated import qualified Control.Exception.Safe as Safe import Data.Annotation-import GHC.Stack-import Data.Typeable import Data.AnnotationSpec () import Data.Maybe+import Data.Typeable+import GHC.Stack instance Eq CallStack where a == b = show a == show b@@ -61,6 +61,10 @@ `shouldBe` [ "! AnnotatedException !" , "Underlying exception type: TestException"+ , ""+ , "show:"+ , "\tTestException"+ , "" , "displayException:" , "\tTestException" , ""@@ -71,12 +75,32 @@ `shouldBe` [ "! AnnotatedException !" , "Underlying exception type: TestException"+ , ""+ , "show:"+ , "\tTestException"+ , "" , "displayException:" , "\tTestException" , "Annotations:" , "\t * Annotation @[Char] \"asdf\"" , "(no callstack available)" ]+ it "shows underlying exception type" $ do+ Left exn <- try $ throwWithCallStack (AnnotatedException [Annotation @String "asdf"] TestException)+ let resultLines =+ [ "! AnnotatedException !"+ , "Underlying exception type: TestException"+ , ""+ , "show:"+ , "\tTestException"+ , ""+ , "displayException:"+ , "\tTestException"+ , "Annotations:"+ , "\t * Annotation @[Char] \"asdf\""+ ]+ take (length resultLines) (lines (displayException (exn :: AnnotatedException SomeException))) `shouldBe`+ resultLines describe "AnnotatedException can fromException a" $ do it "different type" $ do