module CabalGild.Unstable.Exception.NoCabalFileFound where

import qualified CabalGild.Unstable.Type.Flag as Flag
import qualified Control.Monad.Catch as Exception

-- | This exception is thrown when no input or output file has been specified,
-- stdin is a terminal device, and there are no Cabal files in the current
-- directory.
data NoCabalFileFound
  = NoCabalFileFound
  deriving (NoCabalFileFound -> NoCabalFileFound -> Bool
(NoCabalFileFound -> NoCabalFileFound -> Bool)
-> (NoCabalFileFound -> NoCabalFileFound -> Bool)
-> Eq NoCabalFileFound
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NoCabalFileFound -> NoCabalFileFound -> Bool
== :: NoCabalFileFound -> NoCabalFileFound -> Bool
$c/= :: NoCabalFileFound -> NoCabalFileFound -> Bool
/= :: NoCabalFileFound -> NoCabalFileFound -> Bool
Eq, Int -> NoCabalFileFound -> ShowS
[NoCabalFileFound] -> ShowS
NoCabalFileFound -> String
(Int -> NoCabalFileFound -> ShowS)
-> (NoCabalFileFound -> String)
-> ([NoCabalFileFound] -> ShowS)
-> Show NoCabalFileFound
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NoCabalFileFound -> ShowS
showsPrec :: Int -> NoCabalFileFound -> ShowS
$cshow :: NoCabalFileFound -> String
show :: NoCabalFileFound -> String
$cshowList :: [NoCabalFileFound] -> ShowS
showList :: [NoCabalFileFound] -> ShowS
Show)

instance Exception.Exception NoCabalFileFound where
  displayException :: NoCabalFileFound -> String
displayException =
    String -> NoCabalFileFound -> String
forall a b. a -> b -> a
const (String -> NoCabalFileFound -> String)
-> String -> NoCabalFileFound -> String
forall a b. (a -> b) -> a -> b
$
      String
"No package descriptions found in the current directory. Use the --"
        String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
Flag.ioOption
        String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" option to specify a *.cabal file."