{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module System.Linux.Proc.Errors ( ProcError (..) , renderProcError ) where import Data.Text (Text) import qualified Data.Text as Text data ProcError = ProcReadError !FilePath !Text | ProcParseError !FilePath !Text | ProcMemInfoKeyError !Text deriving (ProcError -> ProcError -> Bool (ProcError -> ProcError -> Bool) -> (ProcError -> ProcError -> Bool) -> Eq ProcError forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ProcError -> ProcError -> Bool == :: ProcError -> ProcError -> Bool $c/= :: ProcError -> ProcError -> Bool /= :: ProcError -> ProcError -> Bool Eq, Int -> ProcError -> ShowS [ProcError] -> ShowS ProcError -> FilePath (Int -> ProcError -> ShowS) -> (ProcError -> FilePath) -> ([ProcError] -> ShowS) -> Show ProcError forall a. (Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ProcError -> ShowS showsPrec :: Int -> ProcError -> ShowS $cshow :: ProcError -> FilePath show :: ProcError -> FilePath $cshowList :: [ProcError] -> ShowS showList :: [ProcError] -> ShowS Show) renderProcError :: ProcError -> Text renderProcError :: ProcError -> Text renderProcError = \case ProcReadError FilePath fp Text msg -> [Text] -> Text forall a. Monoid a => [a] -> a mconcat [ Text "Error reading '", FilePath -> Text Text.pack FilePath fp, Text "': ", Text msg ] ProcParseError FilePath fp Text msg -> [Text] -> Text forall a. Monoid a => [a] -> a mconcat [ Text "Parser error on file '", FilePath -> Text Text.pack FilePath fp, Text ": ", Text msg ] ProcMemInfoKeyError Text key -> [Text] -> Text forall a. Monoid a => [a] -> a mconcat [ Text "MemInfo: Key not found: '", Text key, Text "'" ]