From 8f62c1ad5045564d8fd5ddafea877efc2d7fc803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 17 Oct 2026 20:40:33 +0200 Subject: Replace user error with custom error data type --- src/Main.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index aada687..8e89f7c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -20,6 +20,7 @@ import System.Posix.Terminal import System.Posix.Types import Config +import Error import JUnit import Output import Parser.Core @@ -180,14 +181,14 @@ main = do -> case conftool of ToolPath cpath -> return $ ToolPath $ baseDir cpath ToolCabal ccabal -> return $ ToolCabal ccabal - | otherwise -> fail "no test tool defined" + | otherwise -> throwOtherError "no test tool defined" case defaultTool of ToolPath tpath -> case words tpath of (path : _) -> getPermissions path >>= \perms -> do when (not $ executable perms) $ do - fail $ "‘" <> path <> "’ is not executable" - _ -> fail $ "invalid tool argument: ‘" <> tpath <> "’" + throwOtherError $ "‘" <> T.pack path <> "’ is not executable" + _ -> throwOtherError $ "invalid tool argument: ‘" <> T.pack tpath <> "’" ToolCabal _ -> return () files <- if not (null ofiles) @@ -197,7 +198,7 @@ main = do (path, _) -> (path, Nothing) else map (, Nothing) <$> maybe (return []) (getConfigTestFiles) config - when (null files) $ fail $ "No test files" + when (null files) $ throwOtherError $ "no test files" useColor <- case optColor opts of Just use -> return use -- cgit v1.2.3