Skip to content

Commit 4db7688

Browse files
committed
Merge pull request #3 from joneshf/master
Use `toString` check rather than `instanceof` check.
2 parents b45edc4 + 5934815 commit 4db7688

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Control/Monad/Eff/Exception.purs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ foreign import error
1919
\ return new Error(msg);\
2020
\};" :: String -> Error
2121

22-
foreign import message
22+
foreign import message
2323
"function message(e) {\
2424
\ return e.message;\
2525
\}" :: Error -> String
26-
27-
foreign import throwException
26+
27+
foreign import throwException
2828
"function throwException(e) {\
2929
\ return function() {\
3030
\ throw e;\
3131
\ };\
3232
\}" :: forall a eff. Error -> Eff (err :: Exception | eff) a
3333

34-
foreign import catchException
34+
foreign import catchException
3535
"function catchException(c) {\
3636
\ return function(t) {\
3737
\ return function() {\
3838
\ try {\
3939
\ return t();\
4040
\ } catch(e) {\
41-
\ if (e instanceof Error) {\
41+
\ if (e instanceof Error || {}.toString.call(e) === '[object Error]') {\
4242
\ return c(e)();\
4343
\ } else {\
44-
\ throw e;\
44+
\ return c(new Error(e.toString()))();\
4545
\ }\
4646
\ }\
4747
\ };\

0 commit comments

Comments
 (0)