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
(Int -> HsCiError -> ShowS)
-> (HsCiError -> String)
-> ([HsCiError] -> ShowS)
-> Show HsCiError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HsCiError -> ShowS
showsPrec :: Int -> HsCiError -> ShowS
$cshow :: HsCiError -> String
show :: HsCiError -> String
$cshowList :: [HsCiError] -> ShowS
showList :: [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 " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s

class FromHsCiError e where
    fromHsCiError :: HsCiError -> e

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