diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-10-17 14:14:48 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-11-07 09:50:51 +0100 |
commit | ea1236f2cf6d3ef4b739b2ca28f47a3bbed42295 (patch) | |
tree | 3b1801ad9654e657ed0c0b202e316dc42244c56d /app/Process.hs | |
parent | 4521eb7a4b0d4a4ff8cf9153484d0596c5143170 (diff) |
refactor history
Diffstat (limited to 'app/Process.hs')
-rw-r--r-- | app/Process.hs | 12 |
1 files changed, 4 insertions, 8 deletions
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 |