Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/Control/Monad/Eff/Exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The type of Javascript errors

##### Instances
``` purescript
instance showError :: Show Error
Show Error
```

#### `error`
Expand Down Expand Up @@ -74,4 +74,13 @@ main = catchException print do
trace "Exceptions thrown in this block will be logged to the console"
```

#### `throw`

``` purescript
throw :: forall eff a. String -> Eff (err :: EXCEPTION | eff) a
```

A shortcut allowing you to throw an error in one step. Defined as
`throwException <<< error`.


6 changes: 6 additions & 0 deletions src/Control/Monad/Eff/Exception.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Control.Monad.Eff.Exception
, message
, throwException
, catchException
, throw
) where

import Prelude
Expand Down Expand Up @@ -53,3 +54,8 @@ foreign import throwException :: forall a eff. Error -> Eff (err :: EXCEPTION |
-- | trace "Exceptions thrown in this block will be logged to the console"
-- | ```
foreign import catchException :: forall a eff. (Error -> Eff eff a) -> Eff (err :: EXCEPTION | eff) a -> Eff eff a

-- | A shortcut allowing you to throw an error in one step. Defined as
-- | `throwException <<< error`.
throw :: forall eff a. String -> Eff (err :: EXCEPTION | eff) a
throw = throwException <<< error