Skip to content

Commit fc2fbcd

Browse files
committed
Merge pull request #10 from hdgarrood/add-throw
Add throw (as in #8)
2 parents 60b7562 + 9618db2 commit fc2fbcd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

docs/Control/Monad/Eff/Exception.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The type of Javascript errors
2121

2222
##### Instances
2323
``` purescript
24-
instance showError :: Show Error
24+
Show Error
2525
```
2626

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

77+
#### `throw`
78+
79+
``` purescript
80+
throw :: forall eff a. String -> Eff (err :: EXCEPTION | eff) a
81+
```
82+
83+
A shortcut allowing you to throw an error in one step. Defined as
84+
`throwException <<< error`.
85+
7786

src/Control/Monad/Eff/Exception.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Control.Monad.Eff.Exception
88
, message
99
, throwException
1010
, catchException
11+
, throw
1112
) where
1213

1314
import Prelude
@@ -53,3 +54,8 @@ foreign import throwException :: forall a eff. Error -> Eff (err :: EXCEPTION |
5354
-- | trace "Exceptions thrown in this block will be logged to the console"
5455
-- | ```
5556
foreign import catchException :: forall a eff. (Error -> Eff eff a) -> Eff (err :: EXCEPTION | eff) a -> Eff eff a
57+
58+
-- | A shortcut allowing you to throw an error in one step. Defined as
59+
-- | `throwException <<< error`.
60+
throw :: forall eff a. String -> Eff (err :: EXCEPTION | eff) a
61+
throw = throwException <<< error

0 commit comments

Comments
 (0)