diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Process/Shell.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Process/Shell.hs b/src/Process/Shell.hs index 87d22df..24bea95 100644 --- a/src/Process/Shell.hs +++ b/src/Process/Shell.hs @@ -9,11 +9,15 @@ module Process.Shell ( sh, Quotable (..), + ExitCodeException (..), + DecodeException (..), ) where +import Control.Exception (Exception, throw) import Control.Monad import Control.Monad.Reader +import Data.Aeson import Data.ByteString qualified as B import Data.ByteString.Lazy qualified as LB import Data.ByteString.Lazy.UTF8 qualified as LB @@ -67,6 +71,14 @@ instance Outputable T.Text where instance Outputable LT.Text where fromLBS = LT.decodeUtf8 +data DecodeException = DecodeException + deriving (Show) + +instance Exception DecodeException + +instance (FromJSON a) => Outputable a where + fromLBS = fromMaybe (throw DecodeException) . decode + class Quotable a where toString :: a -> String default toString :: (Show a) => a -> String |