1module ErrorTests (errorTests) where
3import Control.Monad.IO.Class
6import GHC.Stack (getCallStack)
9import Effectful.Interpreter
13errorTests = testGroup "Error"
14 [ testCase "error from interpret" test_errorFromInterpret
17test_errorFromInterpret :: Assertion
18test_errorFromInterpret = runIOE $ do
19 result <- runError @String . runNestedErr $ do
20 runError @String nestedErr
21 liftIO $ case result of
22 Left (cs, _) -> assertBool "stack trace points to the correct action" $
23 "nestedErr" == fst (last $ getCallStack cs)
24 Right _ -> assertFailure "error caught by the wrong (inner) handler"
26----------------------------------------
29data NestedErr :: Effect where
30 NestedErr :: NestedErr m ()
32nestedErr :: (HasCallStack, NestedErr :> es) => Eff es ()
33nestedErr = send NestedErr
35runNestedErr :: Error String :> es => Eff (NestedErr : es) a -> Eff es a
36runNestedErr = interpret $ \NestedErr -> throwError "nested error"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list