File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 44
55### Types
66
7- data Exception :: * -> !
7+ type Error = { stack :: String, message :: String }
8+
9+ data Exception :: !
810
911
1012### Values
1113
12- catchException :: forall e r a . (e -> Eff r a) -> Eff (err :: Exception e | r ) a -> Eff r a
14+ catchException :: forall a eff . (Error -> Eff eff a) -> Eff (err :: Exception | eff ) a -> Eff eff a
1315
14- throwException :: forall a e r. e -> Eff (err :: Exception e | r ) a
16+ throwException :: forall a eff. Error -> Eff (err :: Exception | eff ) a
Original file line number Diff line number Diff line change @@ -2,14 +2,16 @@ module Control.Monad.Eff.Exception where
22
33import Control.Monad.Eff
44
5- foreign import data Exception :: * -> !
5+ foreign import data Exception :: !
6+
7+ type Error = { message :: String , stack :: String }
68
79foreign import throwException
810 " function throwException(e) {\
911 \ return function() {\
1012 \ throw e;\
1113 \ };\
12- \}" :: forall a e r . e -> Eff (err :: Exception e | r ) a
14+ \}" :: forall a eff . Error -> Eff (err :: Exception | eff ) a
1315
1416foreign import catchException
1517 " function catchException(c) {\
@@ -18,8 +20,12 @@ foreign import catchException
1820 \ try {\
1921 \ return t();\
2022 \ } catch(e) {\
21- \ return c(e)();\
23+ \ if (e instanceof Error) {\
24+ \ return c(e)();\
25+ \ } else {\
26+ \ throw e;\
27+ \ }\
2228 \ }\
2329 \ };\
2430 \ };\
25- \}" :: forall e r a . (e -> Eff r a ) -> Eff (err :: Exception e | r ) a -> Eff r a
31+ \}" :: forall a eff . (Error -> Eff eff a ) -> Eff (err :: Exception | eff ) a -> Eff eff a
You can’t perform that action at this time.
0 commit comments