-- | Exception handling.

module Control.Exception where

import FFI

-- | Try the given action and catch if there's an error.
onException :: Fay a -> Fay a -> Fay a
onException :: Fay a -> Fay a -> Fay a
onException = [Char] -> Fay a -> Fay a -> Fay a
forall s a. IsString s => s -> a
ffi [Char]
"function() { try { return %1(); } catch(e) { return %2(); } }()"

-- | Try the given action and catch the exception.
catch :: Fay a -> (Automatic e -> Fay a) -> Fay a
catch :: Fay a -> (Automatic e -> Fay a) -> Fay a
catch = [Char] -> Fay a -> (Automatic e -> Fay a) -> Fay a
forall s a. IsString s => s -> a
ffi [Char]
"function() { try { return %1(); } catch(e) { return %2(e); } }()"

-- | Throw an exception.
throw :: Automatic e -> Fay a
throw :: Automatic e -> Fay a
throw = [Char] -> Automatic e -> Fay a
forall s a. IsString s => s -> a
ffi [Char]
"(function() { throw %1 })()"