-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve exceptions rethrown by unwrapAnnotatedHUnitFailure #202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do wonder if the pain we self-inflict by such pervasive use of annotated exceptions will ever end. I do really like them though. 😅
freckle-app/tests/Freckle/App/Test/Hspec/AnnotatedExceptionSpec.hs
Outdated
Show resolved
Hide resolved
Wait, can we back up a bit as to why we need this hook at all? The reason we need to be careful in other scenarios is because we've done an I can't see how our hspec usages would ever run afoul of this with You originally got here because the Am I misunderstanding something? |
I originally got on this track because ghci> :m Test.Hspec Freckle.App.Prelude Freckle.App.Exception
ghci> hspec $ it "" $ 'a' `shouldBe` 'b'
Ghci2[7:9] [✘]
Failures:
<interactive>:7:21:
1) Ghci2[7:9]
expected: 'b'
but got: 'a'
To rerun use: --match "/Ghci2[7:9]/"
Randomized with seed 603656257
Finished in 0.0020 seconds
1 example, 1 failure
*** Exception: ExitFailure 1 But when they're annotated, they print like this: ghci> hspec $ it "" $ checkpointCallStack $ 'a' `shouldBe` 'b'
Ghci2[12:9] [✘]
Failures:
<interactive>:12:9:
1) Ghci2[12:9]
uncaught exception: AnnotatedException
AnnotatedException {annotations = [Annotation @CallStack [("checkpointCallStack",SrcLoc {srcLocPackage = "interactive", srcLocModule = "Ghci2", srcLocFile = "<interactive>", srcLocStartLine = 12, srcLocStartCol = 17, srcLocEndLine = 12, srcLocEndCol = 36})]], exception = HUnitFailure (Just (SrcLoc {srcLocPackage = "interactive", srcLocModule = "Ghci2", srcLocFile = "<interactive>", srcLocStartLine = 12, srcLocStartCol = 43, srcLocEndLine = 12, srcLocEndCol = 53})) (ExpectedButGot Nothing "'b'" "'a'")}
To rerun use: --match "/Ghci2[12:9]/"
Randomized with seed 1536058360
Finished in 0.0002 seconds
1 example, 1 failure
*** Exception: ExitFailure 1
I don't remember why, but there was, it's a real problem that I hit in curricula. I don't think it's unusual.
The only way to get a stack is to |
Note that the new version of I'd be happy to accept a PR exposing anything you needed to copy out |
Assertions happening within your application monad ( |
This replicates a bunch of display logic from
displayException
in annotated-exception that ideally would be exported by that package (cc @parsonsmatt).Closes #201