summaryrefslogtreecommitdiff
path: root/src/Error.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-10-17 20:40:33 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-10-21 20:37:20 +0200
commit8f62c1ad5045564d8fd5ddafea877efc2d7fc803 (patch)
tree4994ec461fe9ec8bde13ea8fea3192604ea3ca4f /src/Error.hs
parente56577e4506c7db72aef9e273cfa00592ca20829 (diff)
Replace user error with custom error data typeHEADmaster
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