summaryrefslogtreecommitdiff
path: root/src/Error.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Error.hs')
-rw-r--r--src/Error.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Error.hs b/src/Error.hs
new file mode 100644
index 0000000..5226912
--- /dev/null
+++ b/src/Error.hs
@@ -0,0 +1,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