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/Run.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Run.hs') diff --git a/src/Run.hs b/src/Run.hs index 53a0275..33c4109 100644 --- a/src/Run.hs +++ b/src/Run.hs @@ -44,6 +44,7 @@ import System.Posix.Signals import System.Process import Config +import Error import GDB import Network import Network.Ip @@ -117,7 +118,7 @@ runTest out opts gdefs test = do when (optForce opts) $ removeDirectoryRecursive testDir `catchIOError` \e -> if isDoesNotExistError e then return () else ioError e exists <- doesPathExist testDir - when exists $ ioError $ userError $ testDir ++ " exists" + when exists $ throwOtherError $ "test directory ‘" <> T.pack testDir <> "’ already exists" createDirectoryIfMissing True testDir failedVar <- newTVarIO Nothing @@ -136,12 +137,12 @@ runTest out opts gdefs test = do let path = takeWhile (/= '\n') cabalOut return $ T.unpack $ T.unwords (T.pack path : args) _ -> do - ioError $ userError $ "failed to find ‘" <> T.unpack name <> "’ executable path using cabal" + throwOtherError $ "failed to find ‘" <> name <> "’ executable path using cabal" | otherwise -> return $ T.unpack arg defaultTool <- case optDefaultTool opts of Just tool -> evalTool tool - Nothing -> ioError $ userError "No test tool defined" + Nothing -> throwOtherError "no test tool defined" procTools <- mapM (sequence . fmap evalTool) $ optProcTools opts mgdb <- if optGDB opts -- cgit v1.2.3