blob: 5226912258b6ba39ae18f71b7125e811ca6a558b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
module Error (
TesterError(..),
throwOtherError
) where
import Control.Exception
import Control.Monad.Except
import Control.Monad.IO.Class
import Data.Text (Text)
import Data.Text qualified as T
data TesterError
= OtherTesterError Text
instance Show TesterError where
show = displayException
instance Exception TesterError where
displayException = \case
OtherTesterError err -> T.unpack err
throwOtherError :: (MonadIO m, MonadError IOException m) => Text -> m a
throwOtherError = liftIO . throwIO . OtherTesterError
|