From ea1236f2cf6d3ef4b739b2ca28f47a3bbed42295 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 17 Oct 2023 14:14:48 +0200 Subject: refactor history --- app/Process.hs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'app/Process.hs') diff --git a/app/Process.hs b/app/Process.hs index 9ce5e46..2b3eaf6 100644 --- a/app/Process.hs +++ b/app/Process.hs @@ -11,34 +11,30 @@ module Process ) where -import Control.Exception (Exception, throwIO) +import Control.Exception (throwIO) import Data.ByteString.Lazy.Char8 qualified as LB import Data.List (intercalate) import Data.String (fromString) import Data.Text qualified as T import Data.Text.Lazy qualified as LT import Data.Text.Lazy.Encoding qualified as LT +import Exception qualified as E import System.Exit (ExitCode (ExitSuccess)) import System.Process.Typed (ProcessConfig, StreamSpec, StreamType (STInput), byteStringInput, readProcess, readProcessStderr) -data ProcessException = ProcessException String ExitCode LB.ByteString - deriving (Show) - -instance Exception ProcessException - sh :: ProcessConfig stdin stdoutIgnored stderr -> IO LB.ByteString sh processConfig = do (exitCode, out, err) <- readProcess processConfig if exitCode == ExitSuccess then pure out - else throwIO $ ProcessException (show processConfig) exitCode err + else throwIO $ E.ProcessException (show processConfig) exitCode err sh_ :: ProcessConfig stdin stdoutIgnored stderr -> IO () sh_ processConfig = do (exitCode, err) <- readProcessStderr processConfig if exitCode == ExitSuccess then pure () - else throwIO $ ProcessException (show processConfig) exitCode err + else throwIO $ E.ProcessException (show processConfig) exitCode err class Quotable a where quote :: a -> String -- cgit v1.2.3