1-- | Support for checked exceptions.
13import Control.Exception
17import Effectful.Internal.Effect
18import Effectful.Internal.Env
19import Effectful.Internal.Monad
20import Effectful.Internal.Utils
22data Error e :: Effect where
26 :: forall e es a. Exception e
27 => Eff (Error e : es) a
28 -> Eff es (Either ([String], e) a)
29runError (Eff m) = unsafeEff $ \es0 -> mask $ \release -> do
31 es <- unsafeConsEnv (IdE (Error @e)) noRelinker es0
32 try (release $ m es) >>= \case
33 Right a -> Right a <$ unsafeTailEnv size0 es
34 Left (WrapErr cs e) -> Left (cs, e) <$ unsafeTailEnv size0 es
37 :: (HasCallStack, Exception e, Error e :> es)
40throwError e = unsafeEff_ $ do
41 throwIO $ WrapErr (ppCallStack <$> getCallStack callStack) e
44 :: (Exception e, Error e :> es)
46 -> ([String] -> e -> Eff es a)
48catchError (Eff m) handler = unsafeEff $ \es -> do
50 m es `catch` \(WrapErr e cs) -> do
52 unEff (handler e cs) es
55 :: (Exception e, Error e :> es)
57 -> Eff es (Either ([String], e) a)
58tryError m = (Right <$> m) `catchError` \es e -> pure (Left (es, e))
60----------------------------------------
63data WrapErr e = WrapErr [String] e
65instance (Show e, Typeable e) => Exception (WrapErr e)
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