module HaskellCI.Error (
    HsCiError (..),
    FromHsCiError (..),
) where

import HaskellCI.Prelude

data HsCiError
    = ShellCheckError String  -- ^ @ShellCheck@ disagrees.
    | ValidationError String  -- ^ used by validations
    | FailError String        -- ^ made by 'fail'.
  deriving (Int -> HsCiError -> ShowS
[HsCiError] -> ShowS
HsCiError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HsCiError] -> ShowS
$cshowList :: [HsCiError] -> ShowS
show :: HsCiError -> String
$cshow :: HsCiError -> String
showsPrec :: Int -> HsCiError -> ShowS
$cshowsPrec :: Int -> HsCiError -> ShowS
Show)

instance Exception HsCiError where
    displayException :: HsCiError -> String
displayException (ShellCheckError String
s) = String
s
    displayException (ValidationError String
s) = String
s
    displayException (FailError String
s)         = String
"PANIC " forall a. [a] -> [a] -> [a]
++ String
s

class FromHsCiError e where
    fromHsCiError :: HsCiError -> e

instance FromHsCiError HsCiError where
    fromHsCiError :: HsCiError -> HsCiError
fromHsCiError = forall a. a -> a
id