{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE DataKinds               #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators           #-}
{-# LANGUAGE FlexibleInstances           #-}
{-# LANGUAGE RankNTypes           #-}

{-|
Module      : GHCup.Errors
Description : GHCup error types
Copyright   : (c) Julian Ospald, 2020
License     : LGPL-3.0
Maintainer  : hasufell@hasufell.de
Stability   : experimental
Portability : portable
-}
module GHCup.Errors where

import           GHCup.Types

import           Codec.Archive
import           Control.Exception.Safe
import           Data.ByteString                ( ByteString )
import           Data.CaseInsensitive           ( CI )
import           Data.Text                      ( Text )
import           Data.Versions
import           Haskus.Utils.Variant
import           System.FilePath
import           Text.PrettyPrint               hiding ( (<>) )
import           Text.PrettyPrint.HughesPJClass hiding ( (<>) )
import           URI.ByteString

import qualified Data.Map.Strict               as M
import qualified Data.Text                     as T
import qualified Data.Text.Encoding            as E
import qualified Data.Text.Encoding.Error      as E
import           Data.Data (Proxy(..))
import Data.Time (Day)



allHFError :: String
allHFError :: FilePath
allHFError = [FilePath] -> FilePath
unlines [FilePath]
allErrors
 where
  format :: Proxy a -> FilePath
format Proxy a
p = FilePath
"GHCup-" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Int -> FilePath
forall a. Show a => a -> FilePath
show (Proxy a -> Int
forall a. HFErrorProject a => Proxy a -> Int
eBase Proxy a
p) FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<>  Proxy a -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc Proxy a
p
  format'' :: a -> Proxy a -> FilePath
format'' a
e Proxy a
p = FilePath
"GHCup-" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Int -> FilePath
forall a. Show a => a -> FilePath
show (a -> Int
forall a. HFErrorProject a => a -> Int
eNum a
e) FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<>  Proxy a -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc Proxy a
p
  format' :: a -> p -> FilePath
format' a
e  p
_ = FilePath
"GHCup-" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Int -> FilePath
forall a. Show a => a -> FilePath
show (a -> Int
forall a. HFErrorProject a => a -> Int
eNum a
e) FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<>  a -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow a
e
  format''' :: a -> p -> FilePath -> FilePath
format''' a
e  p
_ FilePath
str' = FilePath
"GHCup-" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Int -> FilePath
forall a. Show a => a -> FilePath
show (a -> Int
forall a. HFErrorProject a => a -> Int
eNum a
e) FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<>  FilePath
str'
  allErrors :: [FilePath]
allErrors =
    [ FilePath
"# low level errors (1 to 500)"
    , let proxy :: Proxy NoCompatiblePlatform
proxy = Proxy NoCompatiblePlatform
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoCompatiblePlatform in Proxy NoCompatiblePlatform -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoCompatiblePlatform
proxy
    , let proxy :: Proxy NoDownload
proxy = Proxy NoDownload
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoDownload in Proxy NoDownload -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoDownload
proxy
    , let proxy :: Proxy NoUpdate
proxy = Proxy NoUpdate
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoUpdate in Proxy NoUpdate -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoUpdate
proxy
    , let proxy :: Proxy DistroNotFound
proxy = Proxy DistroNotFound
forall {k} (t :: k). Proxy t
Proxy :: Proxy DistroNotFound in Proxy DistroNotFound -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DistroNotFound
proxy
    , let proxy :: Proxy UnknownArchive
proxy = Proxy UnknownArchive
forall {k} (t :: k). Proxy t
Proxy :: Proxy UnknownArchive in Proxy UnknownArchive -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UnknownArchive
proxy
    , let proxy :: Proxy UnsupportedScheme
proxy = Proxy UnsupportedScheme
forall {k} (t :: k). Proxy t
Proxy :: Proxy UnsupportedScheme in Proxy UnsupportedScheme -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UnsupportedScheme
proxy
    , let proxy :: Proxy CopyError
proxy = Proxy CopyError
forall {k} (t :: k). Proxy t
Proxy :: Proxy CopyError in Proxy CopyError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy CopyError
proxy
    , let proxy :: Proxy MergeFileTreeError
proxy = Proxy MergeFileTreeError
forall {k} (t :: k). Proxy t
Proxy :: Proxy MergeFileTreeError in Proxy MergeFileTreeError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy MergeFileTreeError
proxy
    , let proxy :: Proxy TagNotFound
proxy = Proxy TagNotFound
forall {k} (t :: k). Proxy t
Proxy :: Proxy TagNotFound in Proxy TagNotFound -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TagNotFound
proxy
    , let proxy :: Proxy DayNotFound
proxy = Proxy DayNotFound
forall {k} (t :: k). Proxy t
Proxy :: Proxy DayNotFound in Proxy DayNotFound -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DayNotFound
proxy
    , let proxy :: Proxy NextVerNotFound
proxy = Proxy NextVerNotFound
forall {k} (t :: k). Proxy t
Proxy :: Proxy NextVerNotFound in Proxy NextVerNotFound -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NextVerNotFound
proxy
    , let proxy :: Proxy AlreadyInstalled
proxy = Proxy AlreadyInstalled
forall {k} (t :: k). Proxy t
Proxy :: Proxy AlreadyInstalled in Proxy AlreadyInstalled -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy AlreadyInstalled
proxy
    , let proxy :: Proxy DirNotEmpty
proxy = Proxy DirNotEmpty
forall {k} (t :: k). Proxy t
Proxy :: Proxy DirNotEmpty in Proxy DirNotEmpty -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DirNotEmpty
proxy
    , let proxy :: Proxy NotInstalled
proxy = Proxy NotInstalled
forall {k} (t :: k). Proxy t
Proxy :: Proxy NotInstalled in Proxy NotInstalled -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NotInstalled
proxy
    , let proxy :: Proxy UninstallFailed
proxy = Proxy UninstallFailed
forall {k} (t :: k). Proxy t
Proxy :: Proxy UninstallFailed in Proxy UninstallFailed -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UninstallFailed
proxy
    , let proxy :: Proxy NotFoundInPATH
proxy = Proxy NotFoundInPATH
forall {k} (t :: k). Proxy t
Proxy :: Proxy NotFoundInPATH in Proxy NotFoundInPATH -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NotFoundInPATH
proxy
    , let proxy :: Proxy JSONError
proxy = Proxy JSONError
forall {k} (t :: k). Proxy t
Proxy :: Proxy JSONError in Proxy JSONError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy JSONError
proxy
    , let proxy :: Proxy FileDoesNotExistError
proxy = Proxy FileDoesNotExistError
forall {k} (t :: k). Proxy t
Proxy :: Proxy FileDoesNotExistError in Proxy FileDoesNotExistError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy FileDoesNotExistError
proxy
    , let proxy :: Proxy FileAlreadyExistsError
proxy = Proxy FileAlreadyExistsError
forall {k} (t :: k). Proxy t
Proxy :: Proxy FileAlreadyExistsError in Proxy FileAlreadyExistsError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy FileAlreadyExistsError
proxy
    , let proxy :: Proxy TarDirDoesNotExist
proxy = Proxy TarDirDoesNotExist
forall {k} (t :: k). Proxy t
Proxy :: Proxy TarDirDoesNotExist in Proxy TarDirDoesNotExist -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TarDirDoesNotExist
proxy
    , let proxy :: Proxy DigestError
proxy = Proxy DigestError
forall {k} (t :: k). Proxy t
Proxy :: Proxy DigestError in Proxy DigestError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DigestError
proxy
    , let proxy :: Proxy GPGError
proxy = Proxy GPGError
forall {k} (t :: k). Proxy t
Proxy :: Proxy GPGError in Proxy GPGError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy GPGError
proxy
    , let proxy :: Proxy HTTPStatusError
proxy = Proxy HTTPStatusError
forall {k} (t :: k). Proxy t
Proxy :: Proxy HTTPStatusError in Proxy HTTPStatusError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy HTTPStatusError
proxy
    , let proxy :: Proxy MalformedHeaders
proxy = Proxy MalformedHeaders
forall {k} (t :: k). Proxy t
Proxy :: Proxy MalformedHeaders in Proxy MalformedHeaders -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy MalformedHeaders
proxy
    , let proxy :: Proxy HTTPNotModified
proxy = Proxy HTTPNotModified
forall {k} (t :: k). Proxy t
Proxy :: Proxy HTTPNotModified in Proxy HTTPNotModified -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy HTTPNotModified
proxy
    , let proxy :: Proxy NoLocationHeader
proxy = Proxy NoLocationHeader
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoLocationHeader in Proxy NoLocationHeader -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoLocationHeader
proxy
    , let proxy :: Proxy TooManyRedirs
proxy = Proxy TooManyRedirs
forall {k} (t :: k). Proxy t
Proxy :: Proxy TooManyRedirs in Proxy TooManyRedirs -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TooManyRedirs
proxy
    , let proxy :: Proxy PatchFailed
proxy = Proxy PatchFailed
forall {k} (t :: k). Proxy t
Proxy :: Proxy PatchFailed in Proxy PatchFailed -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy PatchFailed
proxy
    , let proxy :: Proxy NoToolRequirements
proxy = Proxy NoToolRequirements
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoToolRequirements in Proxy NoToolRequirements -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoToolRequirements
proxy
    , let proxy :: Proxy InvalidBuildConfig
proxy = Proxy InvalidBuildConfig
forall {k} (t :: k). Proxy t
Proxy :: Proxy InvalidBuildConfig in Proxy InvalidBuildConfig -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy InvalidBuildConfig
proxy
    , let proxy :: Proxy NoToolVersionSet
proxy = Proxy NoToolVersionSet
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoToolVersionSet in Proxy NoToolVersionSet -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoToolVersionSet
proxy
    , let proxy :: Proxy NoNetwork
proxy = Proxy NoNetwork
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoNetwork in Proxy NoNetwork -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoNetwork
proxy
    , let proxy :: Proxy HadrianNotFound
proxy = Proxy HadrianNotFound
forall {k} (t :: k). Proxy t
Proxy :: Proxy HadrianNotFound in Proxy HadrianNotFound -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy HadrianNotFound
proxy
    , let proxy :: Proxy ToolShadowed
proxy = Proxy ToolShadowed
forall {k} (t :: k). Proxy t
Proxy :: Proxy ToolShadowed in Proxy ToolShadowed -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ToolShadowed
proxy
    , let proxy :: Proxy ContentLengthError
proxy = Proxy ContentLengthError
forall {k} (t :: k). Proxy t
Proxy :: Proxy ContentLengthError in Proxy ContentLengthError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ContentLengthError
proxy
    , let proxy :: Proxy DuplicateReleaseChannel
proxy = Proxy DuplicateReleaseChannel
forall {k} (t :: k). Proxy t
Proxy :: Proxy DuplicateReleaseChannel in Proxy DuplicateReleaseChannel -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DuplicateReleaseChannel
proxy
    , let proxy :: Proxy UnsupportedSetupCombo
proxy = Proxy UnsupportedSetupCombo
forall {k} (t :: k). Proxy t
Proxy :: Proxy UnsupportedSetupCombo in Proxy UnsupportedSetupCombo -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UnsupportedSetupCombo
proxy
    , FilePath
""
    , FilePath
"# high level errors (4000+)"
    , let proxy :: Proxy DownloadFailed
proxy = Proxy DownloadFailed
forall {k} (t :: k). Proxy t
Proxy :: Proxy DownloadFailed in Proxy DownloadFailed -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DownloadFailed
proxy
    , let proxy :: Proxy InstallSetError
proxy = Proxy InstallSetError
forall {k} (t :: k). Proxy t
Proxy :: Proxy InstallSetError in Proxy InstallSetError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy InstallSetError
proxy
    , let proxy :: Proxy TestFailed
proxy = Proxy TestFailed
forall {k} (t :: k). Proxy t
Proxy :: Proxy TestFailed in Proxy TestFailed -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TestFailed
proxy
    , let proxy :: Proxy BuildFailed
proxy = Proxy BuildFailed
forall {k} (t :: k). Proxy t
Proxy :: Proxy BuildFailed in Proxy BuildFailed -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy BuildFailed
proxy
    , let proxy :: Proxy GHCupSetError
proxy = Proxy GHCupSetError
forall {k} (t :: k). Proxy t
Proxy :: Proxy GHCupSetError in Proxy GHCupSetError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy GHCupSetError
proxy
    , FilePath
""
    , FilePath
"# true exceptions (500+)"
    , let proxy :: Proxy ParseError
proxy = Proxy ParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy ParseError in Proxy ParseError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ParseError
proxy
    , let proxy :: Proxy UnexpectedListLength
proxy = Proxy UnexpectedListLength
forall {k} (t :: k). Proxy t
Proxy :: Proxy UnexpectedListLength in Proxy UnexpectedListLength -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UnexpectedListLength
proxy
    , let proxy :: Proxy NoUrlBase
proxy = Proxy NoUrlBase
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoUrlBase in Proxy NoUrlBase -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoUrlBase
proxy
    , let proxy :: Proxy DigestMissing
proxy = Proxy DigestMissing
forall {k} (t :: k). Proxy t
Proxy :: Proxy DigestMissing in Proxy DigestMissing -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DigestMissing
proxy
    , FilePath
""
    , FilePath
"# orphans (800+)"
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError in Proxy URIParseError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = SchemaError -> URIParseError
MalformedScheme SchemaError
MissingColon
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedUserInfo
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedQuery
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedFragment
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedHost
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedPort
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedPath
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = Proxy URIParseError
forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = FilePath -> URIParseError
OtherError FilePath
""
      in URIParseError -> Proxy URIParseError -> FilePath
forall {a} {a}.
(HFErrorProject a, HFErrorProject a) =>
a -> Proxy a -> FilePath
format'' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy ArchiveResult
proxy = Proxy ArchiveResult
forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult in Proxy ArchiveResult -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = Proxy ArchiveResult
forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveFatal
      in ArchiveResult -> Proxy ArchiveResult -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = Proxy ArchiveResult
forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveFailed
      in ArchiveResult -> Proxy ArchiveResult -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = Proxy ArchiveResult
forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveWarn
      in ArchiveResult -> Proxy ArchiveResult -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = Proxy ArchiveResult
forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveRetry
      in ArchiveResult -> Proxy ArchiveResult -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = Proxy ArchiveResult
forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveOk
      in ArchiveResult -> Proxy ArchiveResult -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = Proxy ArchiveResult
forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveEOF
      in ArchiveResult -> Proxy ArchiveResult -> FilePath
forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy

    , let proxy :: Proxy ProcessError
proxy = Proxy ProcessError
forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError in Proxy ProcessError -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ProcessError
proxy
    , let proxy :: Proxy ProcessError
proxy = Proxy ProcessError
forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = Int -> FilePath -> [FilePath] -> ProcessError
NonZeroExit Int
0 FilePath
"" []
      in ProcessError -> Proxy ProcessError -> FilePath -> FilePath
forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"A process returned a non-zero exit code."
    , let proxy :: Proxy ProcessError
proxy = Proxy ProcessError
forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = FilePath -> [FilePath] -> ProcessError
PTerminated FilePath
"" []
      in ProcessError -> Proxy ProcessError -> FilePath -> FilePath
forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"A process terminated prematurely."
    , let proxy :: Proxy ProcessError
proxy = Proxy ProcessError
forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = FilePath -> [FilePath] -> ProcessError
PStopped FilePath
"" []
      in ProcessError -> Proxy ProcessError -> FilePath -> FilePath
forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"A process stopped prematurely."
    , let proxy :: Proxy ProcessError
proxy = Proxy ProcessError
forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = FilePath -> [FilePath] -> ProcessError
NoSuchPid FilePath
"" []
      in ProcessError -> Proxy ProcessError -> FilePath -> FilePath
forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"Could not find PID for this process."
    ]


prettyHFError :: (Pretty e, HFErrorProject e) => e -> String
prettyHFError :: forall e. (Pretty e, HFErrorProject e) => e -> FilePath
prettyHFError e
e =
  let errorCode :: FilePath
errorCode = FilePath
"GHCup-" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Int -> FilePath
forall {a}. (Ord a, Num a, Show a) => a -> FilePath
padIntAndShow (e -> Int
forall a. HFErrorProject a => a -> Int
eNum e
e)
  in (FilePath
"[" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath -> FilePath
linkEscapeCode FilePath
errorCode  (FilePath -> FilePath
hfErrorLink FilePath
errorCode) FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"] ") FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> e -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow e
e
 where
  hfErrorLink :: FilePath -> FilePath
hfErrorLink FilePath
errorCode = FilePath
"https://errors.haskell.org/messages/" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
errorCode
  padIntAndShow :: a -> FilePath
padIntAndShow a
i
    | a
i a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
10    = FilePath
"0000" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> a -> FilePath
forall a. Show a => a -> FilePath
show a
i
    | a
i a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
100   = FilePath
"000"  FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> a -> FilePath
forall a. Show a => a -> FilePath
show a
i
    | a
i a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
1000  = FilePath
"00"   FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> a -> FilePath
forall a. Show a => a -> FilePath
show a
i
    | a
i a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
10000 = FilePath
"0"    FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> a -> FilePath
forall a. Show a => a -> FilePath
show a
i
    | Bool
otherwise =           a -> FilePath
forall a. Show a => a -> FilePath
show a
i

class HFErrorProject a where
  eNum :: a -> Int
  eNum a
_ = Proxy a -> Int
forall a. HFErrorProject a => Proxy a -> Int
eBase (Proxy a
forall {k} (t :: k). Proxy t
Proxy :: Proxy a)

  eBase :: Proxy a -> Int

  eDesc :: Proxy a -> String

linkEscapeCode :: String -> String -> String
linkEscapeCode :: FilePath -> FilePath -> FilePath
linkEscapeCode FilePath
linkText FilePath
link = FilePath
"\ESC]8;;" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
link FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"\ESC\\" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
linkText FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"\ESC]8;;\ESC\\"


    ------------------------
    --[ Low-level errors ]--
    ------------------------



-- | A compatible platform could not be found.
data NoCompatiblePlatform = NoCompatiblePlatform String -- the platform we got
  deriving Int -> NoCompatiblePlatform -> FilePath -> FilePath
[NoCompatiblePlatform] -> FilePath -> FilePath
NoCompatiblePlatform -> FilePath
(Int -> NoCompatiblePlatform -> FilePath -> FilePath)
-> (NoCompatiblePlatform -> FilePath)
-> ([NoCompatiblePlatform] -> FilePath -> FilePath)
-> Show NoCompatiblePlatform
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoCompatiblePlatform -> FilePath -> FilePath
showsPrec :: Int -> NoCompatiblePlatform -> FilePath -> FilePath
$cshow :: NoCompatiblePlatform -> FilePath
show :: NoCompatiblePlatform -> FilePath
$cshowList :: [NoCompatiblePlatform] -> FilePath -> FilePath
showList :: [NoCompatiblePlatform] -> FilePath -> FilePath
Show

instance Pretty NoCompatiblePlatform where
  pPrint :: NoCompatiblePlatform -> Doc
pPrint (NoCompatiblePlatform FilePath
str') =
    FilePath -> Doc
text (FilePath
"Could not find a compatible platform. Got: " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
str')

instance HFErrorProject NoCompatiblePlatform where
  eBase :: Proxy NoCompatiblePlatform -> Int
eBase Proxy NoCompatiblePlatform
_ = Int
1
  eDesc :: Proxy NoCompatiblePlatform -> FilePath
eDesc Proxy NoCompatiblePlatform
_ = FilePath
"No compatible platform could be found"

-- | Unable to find a download for the requested version/distro.
data NoDownload = NoDownload GHCTargetVersion Tool (Maybe PlatformRequest)
                | NoDownload' GlobalTool
  deriving Int -> NoDownload -> FilePath -> FilePath
[NoDownload] -> FilePath -> FilePath
NoDownload -> FilePath
(Int -> NoDownload -> FilePath -> FilePath)
-> (NoDownload -> FilePath)
-> ([NoDownload] -> FilePath -> FilePath)
-> Show NoDownload
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoDownload -> FilePath -> FilePath
showsPrec :: Int -> NoDownload -> FilePath -> FilePath
$cshow :: NoDownload -> FilePath
show :: NoDownload -> FilePath
$cshowList :: [NoDownload] -> FilePath -> FilePath
showList :: [NoDownload] -> FilePath -> FilePath
Show

instance Pretty NoDownload where
  pPrint :: NoDownload -> Doc
pPrint (NoDownload tver :: GHCTargetVersion
tver@(GHCTargetVersion Maybe Text
mtarget Version
vv) Tool
tool Maybe PlatformRequest
mpfreq)
    | (Just Text
target) <- Maybe Text
mtarget
    , Text
target Text -> [Text] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (FilePath -> Text
T.pack (FilePath -> Text) -> (Tool -> FilePath) -> Tool -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tool -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow (Tool -> Text) -> [Tool] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tool -> Tool -> [Tool]
forall a. Enum a => a -> a -> [a]
enumFromTo (Tool
forall a. Bounded a => a
minBound :: Tool) (Tool
forall a. Bounded a => a
maxBound :: Tool))
    = FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"Unable to find a download for "
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Tool -> FilePath
forall a. Show a => a -> FilePath
show Tool
tool
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" version '"
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Text -> FilePath
T.unpack (GHCTargetVersion -> Text
tVerToText GHCTargetVersion
tver)
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
-> (PlatformRequest -> FilePath)
-> Maybe PlatformRequest
-> FilePath
forall b a. b -> (a -> b) -> Maybe a -> b
maybe FilePath
"'\n" (\PlatformRequest
pfreq -> FilePath
"' on detected platform " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> PlatformRequest -> FilePath
pfReqToString PlatformRequest
pfreq FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"\n") Maybe PlatformRequest
mpfreq
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"Perhaps you meant: 'ghcup <command> "
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Text -> FilePath
T.unpack Text
target
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" "
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Text -> FilePath
T.unpack (Version -> Text
prettyVer Version
vv)
             FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"'"
    | Bool
otherwise = FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"Unable to find a download for " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Text -> FilePath
T.unpack (GHCTargetVersion -> Text
tVerToText GHCTargetVersion
tver)
  pPrint (NoDownload' GlobalTool
globalTool) = FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"Unable to find a download for " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> GlobalTool -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow GlobalTool
globalTool

instance HFErrorProject NoDownload where
  eBase :: Proxy NoDownload -> Int
eBase Proxy NoDownload
_ = Int
10
  eDesc :: Proxy NoDownload -> FilePath
eDesc Proxy NoDownload
_ = FilePath
"Unable to find a download for the requested version/distro."

-- | No update available or necessary.
data NoUpdate = NoUpdate
  deriving Int -> NoUpdate -> FilePath -> FilePath
[NoUpdate] -> FilePath -> FilePath
NoUpdate -> FilePath
(Int -> NoUpdate -> FilePath -> FilePath)
-> (NoUpdate -> FilePath)
-> ([NoUpdate] -> FilePath -> FilePath)
-> Show NoUpdate
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoUpdate -> FilePath -> FilePath
showsPrec :: Int -> NoUpdate -> FilePath -> FilePath
$cshow :: NoUpdate -> FilePath
show :: NoUpdate -> FilePath
$cshowList :: [NoUpdate] -> FilePath -> FilePath
showList :: [NoUpdate] -> FilePath -> FilePath
Show

instance Pretty NoUpdate where
  pPrint :: NoUpdate -> Doc
pPrint NoUpdate
NoUpdate = FilePath -> Doc
text (Proxy NoUpdate -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy NoUpdate
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoUpdate))

instance HFErrorProject NoUpdate where
  eBase :: Proxy NoUpdate -> Int
eBase Proxy NoUpdate
_ = Int
20
  eDesc :: Proxy NoUpdate -> FilePath
eDesc Proxy NoUpdate
_ = FilePath
"No update available or necessary."

-- | The Architecture is unknown and unsupported.
data NoCompatibleArch = NoCompatibleArch String
  deriving Int -> NoCompatibleArch -> FilePath -> FilePath
[NoCompatibleArch] -> FilePath -> FilePath
NoCompatibleArch -> FilePath
(Int -> NoCompatibleArch -> FilePath -> FilePath)
-> (NoCompatibleArch -> FilePath)
-> ([NoCompatibleArch] -> FilePath -> FilePath)
-> Show NoCompatibleArch
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoCompatibleArch -> FilePath -> FilePath
showsPrec :: Int -> NoCompatibleArch -> FilePath -> FilePath
$cshow :: NoCompatibleArch -> FilePath
show :: NoCompatibleArch -> FilePath
$cshowList :: [NoCompatibleArch] -> FilePath -> FilePath
showList :: [NoCompatibleArch] -> FilePath -> FilePath
Show

instance Pretty NoCompatibleArch where
  pPrint :: NoCompatibleArch -> Doc
pPrint (NoCompatibleArch FilePath
arch) =
    FilePath -> Doc
text (FilePath
"The Architecture is unknown or unsupported. Got: " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
arch)

instance HFErrorProject NoCompatibleArch where
  eBase :: Proxy NoCompatibleArch -> Int
eBase Proxy NoCompatibleArch
_ = Int
30
  eDesc :: Proxy NoCompatibleArch -> FilePath
eDesc Proxy NoCompatibleArch
_ = FilePath
"The Architecture is unknown and unsupported"

-- | Unable to figure out the distribution of the host.
data DistroNotFound = DistroNotFound
  deriving Int -> DistroNotFound -> FilePath -> FilePath
[DistroNotFound] -> FilePath -> FilePath
DistroNotFound -> FilePath
(Int -> DistroNotFound -> FilePath -> FilePath)
-> (DistroNotFound -> FilePath)
-> ([DistroNotFound] -> FilePath -> FilePath)
-> Show DistroNotFound
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> DistroNotFound -> FilePath -> FilePath
showsPrec :: Int -> DistroNotFound -> FilePath -> FilePath
$cshow :: DistroNotFound -> FilePath
show :: DistroNotFound -> FilePath
$cshowList :: [DistroNotFound] -> FilePath -> FilePath
showList :: [DistroNotFound] -> FilePath -> FilePath
Show

instance Pretty DistroNotFound where
  pPrint :: DistroNotFound -> Doc
pPrint DistroNotFound
DistroNotFound =
    FilePath -> Doc
text (Proxy DistroNotFound -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy DistroNotFound
forall {k} (t :: k). Proxy t
Proxy :: Proxy DistroNotFound))

instance HFErrorProject DistroNotFound where
  eBase :: Proxy DistroNotFound -> Int
eBase Proxy DistroNotFound
_ = Int
40
  eDesc :: Proxy DistroNotFound -> FilePath
eDesc Proxy DistroNotFound
_ = FilePath
"Unable to figure out the distribution of the host"

-- | The archive format is unknown. We don't know how to extract it.
data UnknownArchive = UnknownArchive FilePath
  deriving Int -> UnknownArchive -> FilePath -> FilePath
[UnknownArchive] -> FilePath -> FilePath
UnknownArchive -> FilePath
(Int -> UnknownArchive -> FilePath -> FilePath)
-> (UnknownArchive -> FilePath)
-> ([UnknownArchive] -> FilePath -> FilePath)
-> Show UnknownArchive
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> UnknownArchive -> FilePath -> FilePath
showsPrec :: Int -> UnknownArchive -> FilePath -> FilePath
$cshow :: UnknownArchive -> FilePath
show :: UnknownArchive -> FilePath
$cshowList :: [UnknownArchive] -> FilePath -> FilePath
showList :: [UnknownArchive] -> FilePath -> FilePath
Show

instance Pretty UnknownArchive where
  pPrint :: UnknownArchive -> Doc
pPrint (UnknownArchive FilePath
file) =
    FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"The archive format is unknown. We don't know how to extract the file " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
file

instance HFErrorProject UnknownArchive where
  eBase :: Proxy UnknownArchive -> Int
eBase Proxy UnknownArchive
_ = Int
50
  eDesc :: Proxy UnknownArchive -> FilePath
eDesc Proxy UnknownArchive
_ = FilePath
"The archive format is unknown. We don't know how to extract it."

-- | The scheme is not supported (such as ftp).
data UnsupportedScheme = UnsupportedScheme
  deriving Int -> UnsupportedScheme -> FilePath -> FilePath
[UnsupportedScheme] -> FilePath -> FilePath
UnsupportedScheme -> FilePath
(Int -> UnsupportedScheme -> FilePath -> FilePath)
-> (UnsupportedScheme -> FilePath)
-> ([UnsupportedScheme] -> FilePath -> FilePath)
-> Show UnsupportedScheme
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> UnsupportedScheme -> FilePath -> FilePath
showsPrec :: Int -> UnsupportedScheme -> FilePath -> FilePath
$cshow :: UnsupportedScheme -> FilePath
show :: UnsupportedScheme -> FilePath
$cshowList :: [UnsupportedScheme] -> FilePath -> FilePath
showList :: [UnsupportedScheme] -> FilePath -> FilePath
Show

instance Pretty UnsupportedScheme where
  pPrint :: UnsupportedScheme -> Doc
pPrint UnsupportedScheme
UnsupportedScheme =
    FilePath -> Doc
text (Proxy UnsupportedScheme -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy UnsupportedScheme
forall {k} (t :: k). Proxy t
Proxy :: Proxy UnsupportedScheme))

instance HFErrorProject UnsupportedScheme where
  eBase :: Proxy UnsupportedScheme -> Int
eBase Proxy UnsupportedScheme
_ = Int
60
  eDesc :: Proxy UnsupportedScheme -> FilePath
eDesc Proxy UnsupportedScheme
_ = FilePath
"The scheme is not supported (such as ftp)."

-- | Unable to copy a file.
data CopyError = CopyError String
  deriving Int -> CopyError -> FilePath -> FilePath
[CopyError] -> FilePath -> FilePath
CopyError -> FilePath
(Int -> CopyError -> FilePath -> FilePath)
-> (CopyError -> FilePath)
-> ([CopyError] -> FilePath -> FilePath)
-> Show CopyError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> CopyError -> FilePath -> FilePath
showsPrec :: Int -> CopyError -> FilePath -> FilePath
$cshow :: CopyError -> FilePath
show :: CopyError -> FilePath
$cshowList :: [CopyError] -> FilePath -> FilePath
showList :: [CopyError] -> FilePath -> FilePath
Show

instance Pretty CopyError where
  pPrint :: CopyError -> Doc
pPrint (CopyError FilePath
reason) =
    FilePath -> Doc
text (FilePath
"Unable to copy a file. Reason was: " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
reason)

instance HFErrorProject CopyError where
  eBase :: Proxy CopyError -> Int
eBase Proxy CopyError
_ = Int
70
  eDesc :: Proxy CopyError -> FilePath
eDesc Proxy CopyError
_ = FilePath
"Unable to copy a file."

-- | Unable to merge file trees.
data MergeFileTreeError = MergeFileTreeError IOException FilePath FilePath
  deriving Int -> MergeFileTreeError -> FilePath -> FilePath
[MergeFileTreeError] -> FilePath -> FilePath
MergeFileTreeError -> FilePath
(Int -> MergeFileTreeError -> FilePath -> FilePath)
-> (MergeFileTreeError -> FilePath)
-> ([MergeFileTreeError] -> FilePath -> FilePath)
-> Show MergeFileTreeError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> MergeFileTreeError -> FilePath -> FilePath
showsPrec :: Int -> MergeFileTreeError -> FilePath -> FilePath
$cshow :: MergeFileTreeError -> FilePath
show :: MergeFileTreeError -> FilePath
$cshowList :: [MergeFileTreeError] -> FilePath -> FilePath
showList :: [MergeFileTreeError] -> FilePath -> FilePath
Show

instance Pretty MergeFileTreeError where
  pPrint :: MergeFileTreeError -> Doc
pPrint (MergeFileTreeError IOException
e FilePath
from FilePath
to) =
    FilePath -> Doc
text FilePath
"Failed to merge file tree from" Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
from Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"to" Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
to Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nexception was:" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (IOException -> FilePath
forall e. Exception e => e -> FilePath
displayException IOException
e)
     Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\n...you may need to delete" Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
to Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"manually. Make sure it's gone."

instance HFErrorProject MergeFileTreeError where
  eBase :: Proxy MergeFileTreeError -> Int
eBase Proxy MergeFileTreeError
_ = Int
80
  eDesc :: Proxy MergeFileTreeError -> FilePath
eDesc Proxy MergeFileTreeError
_ = FilePath
"Unable to merge file trees during installation"

-- | Unable to find a tag of a tool.
data TagNotFound = TagNotFound Tag Tool
  deriving Int -> TagNotFound -> FilePath -> FilePath
[TagNotFound] -> FilePath -> FilePath
TagNotFound -> FilePath
(Int -> TagNotFound -> FilePath -> FilePath)
-> (TagNotFound -> FilePath)
-> ([TagNotFound] -> FilePath -> FilePath)
-> Show TagNotFound
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> TagNotFound -> FilePath -> FilePath
showsPrec :: Int -> TagNotFound -> FilePath -> FilePath
$cshow :: TagNotFound -> FilePath
show :: TagNotFound -> FilePath
$cshowList :: [TagNotFound] -> FilePath -> FilePath
showList :: [TagNotFound] -> FilePath -> FilePath
Show

instance Pretty TagNotFound where
  pPrint :: TagNotFound -> Doc
pPrint (TagNotFound Tag
tag Tool
tool) =
    FilePath -> Doc
text FilePath
"Unable to find tag" Doc -> Doc -> Doc
<+> Tag -> Doc
forall a. Pretty a => a -> Doc
pPrint Tag
tag Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of tool" Doc -> Doc -> Doc
<+> Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool

instance HFErrorProject TagNotFound where
  eBase :: Proxy TagNotFound -> Int
eBase Proxy TagNotFound
_ = Int
90
  eDesc :: Proxy TagNotFound -> FilePath
eDesc Proxy TagNotFound
_ = FilePath
"Unable to find a tag of a tool"

-- | Unable to find a release day of a tool
data DayNotFound = DayNotFound Day Tool (Maybe Day)
  deriving Int -> DayNotFound -> FilePath -> FilePath
[DayNotFound] -> FilePath -> FilePath
DayNotFound -> FilePath
(Int -> DayNotFound -> FilePath -> FilePath)
-> (DayNotFound -> FilePath)
-> ([DayNotFound] -> FilePath -> FilePath)
-> Show DayNotFound
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> DayNotFound -> FilePath -> FilePath
showsPrec :: Int -> DayNotFound -> FilePath -> FilePath
$cshow :: DayNotFound -> FilePath
show :: DayNotFound -> FilePath
$cshowList :: [DayNotFound] -> FilePath -> FilePath
showList :: [DayNotFound] -> FilePath -> FilePath
Show

instance Pretty DayNotFound where
  pPrint :: DayNotFound -> Doc
pPrint (DayNotFound Day
day Tool
tool Maybe Day
Nothing) =
    FilePath -> Doc
text FilePath
"Unable to find release date" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Day -> FilePath
forall a. Show a => a -> FilePath
show Day
day) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of tool" Doc -> Doc -> Doc
<+> Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool
  pPrint (DayNotFound Day
day Tool
tool (Just Day
alternateDay)) =
    FilePath -> Doc
text FilePath
"Unable to find release date" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Day -> FilePath
forall a. Show a => a -> FilePath
show Day
day) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of tool" Doc -> Doc -> Doc
<+> Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+>
      FilePath -> Doc
text FilePath
"but found an alternative date" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Day -> FilePath
forall a. Show a => a -> FilePath
show Day
alternateDay)

instance HFErrorProject DayNotFound where
  eBase :: Proxy DayNotFound -> Int
eBase Proxy DayNotFound
_ = Int
95
  eDesc :: Proxy DayNotFound -> FilePath
eDesc Proxy DayNotFound
_ = FilePath
"Unable to find a release date of a tool"

-- | Unable to find the next version of a tool (the one after the currently
-- set one).
data NextVerNotFound = NextVerNotFound Tool
  deriving Int -> NextVerNotFound -> FilePath -> FilePath
[NextVerNotFound] -> FilePath -> FilePath
NextVerNotFound -> FilePath
(Int -> NextVerNotFound -> FilePath -> FilePath)
-> (NextVerNotFound -> FilePath)
-> ([NextVerNotFound] -> FilePath -> FilePath)
-> Show NextVerNotFound
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NextVerNotFound -> FilePath -> FilePath
showsPrec :: Int -> NextVerNotFound -> FilePath -> FilePath
$cshow :: NextVerNotFound -> FilePath
show :: NextVerNotFound -> FilePath
$cshowList :: [NextVerNotFound] -> FilePath -> FilePath
showList :: [NextVerNotFound] -> FilePath -> FilePath
Show

instance Pretty NextVerNotFound where
  pPrint :: NextVerNotFound -> Doc
pPrint (NextVerNotFound Tool
tool) =
    FilePath -> Doc
text FilePath
"Unable to find next (the one after the currently set one) version of tool" Doc -> Doc -> Doc
<+> Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool

instance HFErrorProject NextVerNotFound where
  eBase :: Proxy NextVerNotFound -> Int
eBase Proxy NextVerNotFound
_ = Int
100
  eDesc :: Proxy NextVerNotFound -> FilePath
eDesc Proxy NextVerNotFound
_ = FilePath
"Unable to find the next version of a tool (the one after the currently set one)"

-- | The tool (such as GHC) is already installed with that version.
data AlreadyInstalled = AlreadyInstalled Tool Version
  deriving Int -> AlreadyInstalled -> FilePath -> FilePath
[AlreadyInstalled] -> FilePath -> FilePath
AlreadyInstalled -> FilePath
(Int -> AlreadyInstalled -> FilePath -> FilePath)
-> (AlreadyInstalled -> FilePath)
-> ([AlreadyInstalled] -> FilePath -> FilePath)
-> Show AlreadyInstalled
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> AlreadyInstalled -> FilePath -> FilePath
showsPrec :: Int -> AlreadyInstalled -> FilePath -> FilePath
$cshow :: AlreadyInstalled -> FilePath
show :: AlreadyInstalled -> FilePath
$cshowList :: [AlreadyInstalled] -> FilePath -> FilePath
showList :: [AlreadyInstalled] -> FilePath -> FilePath
Show

instance Pretty AlreadyInstalled where
  pPrint :: AlreadyInstalled -> Doc
pPrint (AlreadyInstalled Tool
tool Version
ver') =
    (Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
text FilePath
"-" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Version -> Doc
forall a. Pretty a => a -> Doc
pPrint Version
ver') Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"is already installed;"
    Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"if you really want to reinstall it, you may want to run 'ghcup install" Doc -> Doc -> Doc
<+> Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"--force" Doc -> Doc -> Doc
<+> (Version -> Doc
forall a. Pretty a => a -> Doc
pPrint Version
ver' Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
text FilePath
"'")

instance HFErrorProject AlreadyInstalled where
  eBase :: Proxy AlreadyInstalled -> Int
eBase Proxy AlreadyInstalled
_ = Int
110
  eDesc :: Proxy AlreadyInstalled -> FilePath
eDesc Proxy AlreadyInstalled
_ = FilePath
"The tool (such as GHC) is already installed with that version"

-- | The Directory is supposed to be empty, but wasn't.
data DirNotEmpty = DirNotEmpty {DirNotEmpty -> FilePath
path :: FilePath}
  deriving Int -> DirNotEmpty -> FilePath -> FilePath
[DirNotEmpty] -> FilePath -> FilePath
DirNotEmpty -> FilePath
(Int -> DirNotEmpty -> FilePath -> FilePath)
-> (DirNotEmpty -> FilePath)
-> ([DirNotEmpty] -> FilePath -> FilePath)
-> Show DirNotEmpty
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> DirNotEmpty -> FilePath -> FilePath
showsPrec :: Int -> DirNotEmpty -> FilePath -> FilePath
$cshow :: DirNotEmpty -> FilePath
show :: DirNotEmpty -> FilePath
$cshowList :: [DirNotEmpty] -> FilePath -> FilePath
showList :: [DirNotEmpty] -> FilePath -> FilePath
Show

instance Pretty DirNotEmpty where
  pPrint :: DirNotEmpty -> Doc
pPrint (DirNotEmpty FilePath
path) = do
    FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"The directory was expected to be empty, but isn't: " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
path

instance HFErrorProject DirNotEmpty where
  eBase :: Proxy DirNotEmpty -> Int
eBase Proxy DirNotEmpty
_ = Int
120
  eDesc :: Proxy DirNotEmpty -> FilePath
eDesc Proxy DirNotEmpty
_ = FilePath
"The Directory is supposed to be empty, but wasn't"

-- | The tool is not installed. Some operations rely on a tool
-- to be installed (such as setting the current GHC version).
data NotInstalled = NotInstalled Tool GHCTargetVersion
  deriving Int -> NotInstalled -> FilePath -> FilePath
[NotInstalled] -> FilePath -> FilePath
NotInstalled -> FilePath
(Int -> NotInstalled -> FilePath -> FilePath)
-> (NotInstalled -> FilePath)
-> ([NotInstalled] -> FilePath -> FilePath)
-> Show NotInstalled
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NotInstalled -> FilePath -> FilePath
showsPrec :: Int -> NotInstalled -> FilePath -> FilePath
$cshow :: NotInstalled -> FilePath
show :: NotInstalled -> FilePath
$cshowList :: [NotInstalled] -> FilePath -> FilePath
showList :: [NotInstalled] -> FilePath -> FilePath
Show

instance Pretty NotInstalled where
  pPrint :: NotInstalled -> Doc
pPrint (NotInstalled Tool
tool GHCTargetVersion
ver) =
    FilePath -> Doc
text FilePath
"The version" Doc -> Doc -> Doc
<+> GHCTargetVersion -> Doc
forall a. Pretty a => a -> Doc
pPrint GHCTargetVersion
ver Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of the tool" Doc -> Doc -> Doc
<+> Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"is not installed."

instance HFErrorProject NotInstalled where
  eBase :: Proxy NotInstalled -> Int
eBase Proxy NotInstalled
_ = Int
130
  eDesc :: Proxy NotInstalled -> FilePath
eDesc Proxy NotInstalled
_ = FilePath
"The required tool is not installed"

data UninstallFailed = UninstallFailed FilePath [FilePath]
  deriving Int -> UninstallFailed -> FilePath -> FilePath
[UninstallFailed] -> FilePath -> FilePath
UninstallFailed -> FilePath
(Int -> UninstallFailed -> FilePath -> FilePath)
-> (UninstallFailed -> FilePath)
-> ([UninstallFailed] -> FilePath -> FilePath)
-> Show UninstallFailed
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> UninstallFailed -> FilePath -> FilePath
showsPrec :: Int -> UninstallFailed -> FilePath -> FilePath
$cshow :: UninstallFailed -> FilePath
show :: UninstallFailed -> FilePath
$cshowList :: [UninstallFailed] -> FilePath -> FilePath
showList :: [UninstallFailed] -> FilePath -> FilePath
Show

instance Pretty UninstallFailed where
  pPrint :: UninstallFailed -> Doc
pPrint (UninstallFailed FilePath
dir [FilePath]
files) =
    FilePath -> Doc
text FilePath
"The following files survived uninstallation: " Doc -> Doc -> Doc
<+> [FilePath] -> Doc
forall a. Pretty a => a -> Doc
pPrint [FilePath]
files Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"...consider removing" Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
dir Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"manually."

instance HFErrorProject UninstallFailed where
  eBase :: Proxy UninstallFailed -> Int
eBase Proxy UninstallFailed
_ = Int
140
  eDesc :: Proxy UninstallFailed -> FilePath
eDesc Proxy UninstallFailed
_ = FilePath
"Uninstallation failed with leftover files"

-- | An executable was expected to be in PATH, but was not found.
data NotFoundInPATH = NotFoundInPATH FilePath
  deriving Int -> NotFoundInPATH -> FilePath -> FilePath
[NotFoundInPATH] -> FilePath -> FilePath
NotFoundInPATH -> FilePath
(Int -> NotFoundInPATH -> FilePath -> FilePath)
-> (NotFoundInPATH -> FilePath)
-> ([NotFoundInPATH] -> FilePath -> FilePath)
-> Show NotFoundInPATH
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NotFoundInPATH -> FilePath -> FilePath
showsPrec :: Int -> NotFoundInPATH -> FilePath -> FilePath
$cshow :: NotFoundInPATH -> FilePath
show :: NotFoundInPATH -> FilePath
$cshowList :: [NotFoundInPATH] -> FilePath -> FilePath
showList :: [NotFoundInPATH] -> FilePath -> FilePath
Show

instance Exception NotFoundInPATH

instance Pretty NotFoundInPATH where
  pPrint :: NotFoundInPATH -> Doc
pPrint (NotFoundInPATH FilePath
exe) =
    FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"The exe " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
exe FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" was not found in PATH."

instance HFErrorProject NotFoundInPATH where
  eBase :: Proxy NotFoundInPATH -> Int
eBase Proxy NotFoundInPATH
_ = Int
150
  eDesc :: Proxy NotFoundInPATH -> FilePath
eDesc Proxy NotFoundInPATH
_ = FilePath
"An executable was expected to be in PATH, but was not found"

-- | JSON decoding failed.
data JSONError = JSONDecodeError String
  deriving Int -> JSONError -> FilePath -> FilePath
[JSONError] -> FilePath -> FilePath
JSONError -> FilePath
(Int -> JSONError -> FilePath -> FilePath)
-> (JSONError -> FilePath)
-> ([JSONError] -> FilePath -> FilePath)
-> Show JSONError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> JSONError -> FilePath -> FilePath
showsPrec :: Int -> JSONError -> FilePath -> FilePath
$cshow :: JSONError -> FilePath
show :: JSONError -> FilePath
$cshowList :: [JSONError] -> FilePath -> FilePath
showList :: [JSONError] -> FilePath -> FilePath
Show

instance Pretty JSONError where
  pPrint :: JSONError -> Doc
pPrint (JSONDecodeError FilePath
err) =
    FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"JSON decoding failed with: " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
err

instance HFErrorProject JSONError where
  eBase :: Proxy JSONError -> Int
eBase Proxy JSONError
_ = Int
160
  eDesc :: Proxy JSONError -> FilePath
eDesc Proxy JSONError
_ = FilePath
"JSON decoding failed"

-- | A file that is supposed to exist does not exist
-- (e.g. when we use file scheme to "download" something).
data FileDoesNotExistError = FileDoesNotExistError FilePath
  deriving Int -> FileDoesNotExistError -> FilePath -> FilePath
[FileDoesNotExistError] -> FilePath -> FilePath
FileDoesNotExistError -> FilePath
(Int -> FileDoesNotExistError -> FilePath -> FilePath)
-> (FileDoesNotExistError -> FilePath)
-> ([FileDoesNotExistError] -> FilePath -> FilePath)
-> Show FileDoesNotExistError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> FileDoesNotExistError -> FilePath -> FilePath
showsPrec :: Int -> FileDoesNotExistError -> FilePath -> FilePath
$cshow :: FileDoesNotExistError -> FilePath
show :: FileDoesNotExistError -> FilePath
$cshowList :: [FileDoesNotExistError] -> FilePath -> FilePath
showList :: [FileDoesNotExistError] -> FilePath -> FilePath
Show

instance Pretty FileDoesNotExistError where
  pPrint :: FileDoesNotExistError -> Doc
pPrint (FileDoesNotExistError FilePath
file) =
    FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"File " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
file FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" does not exist."

instance HFErrorProject FileDoesNotExistError where
  eBase :: Proxy FileDoesNotExistError -> Int
eBase Proxy FileDoesNotExistError
_ = Int
170
  eDesc :: Proxy FileDoesNotExistError -> FilePath
eDesc Proxy FileDoesNotExistError
_ = FilePath
"A file that is supposed to exist does not exist (oops)"

-- | The file already exists
-- (e.g. when we use isolated installs with the same path).
-- (e.g. This is done to prevent any overwriting)
data FileAlreadyExistsError = FileAlreadyExistsError FilePath
  deriving Int -> FileAlreadyExistsError -> FilePath -> FilePath
[FileAlreadyExistsError] -> FilePath -> FilePath
FileAlreadyExistsError -> FilePath
(Int -> FileAlreadyExistsError -> FilePath -> FilePath)
-> (FileAlreadyExistsError -> FilePath)
-> ([FileAlreadyExistsError] -> FilePath -> FilePath)
-> Show FileAlreadyExistsError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> FileAlreadyExistsError -> FilePath -> FilePath
showsPrec :: Int -> FileAlreadyExistsError -> FilePath -> FilePath
$cshow :: FileAlreadyExistsError -> FilePath
show :: FileAlreadyExistsError -> FilePath
$cshowList :: [FileAlreadyExistsError] -> FilePath -> FilePath
showList :: [FileAlreadyExistsError] -> FilePath -> FilePath
Show

instance Pretty FileAlreadyExistsError where
  pPrint :: FileAlreadyExistsError -> Doc
pPrint (FileAlreadyExistsError FilePath
file) =
    FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"File " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
file FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" Already exists."

instance HFErrorProject FileAlreadyExistsError where
  eBase :: Proxy FileAlreadyExistsError -> Int
eBase Proxy FileAlreadyExistsError
_ = Int
180
  eDesc :: Proxy FileAlreadyExistsError -> FilePath
eDesc Proxy FileAlreadyExistsError
_ = FilePath
"A file already exists that wasn't expected to exist"

data TarDirDoesNotExist = TarDirDoesNotExist TarDir
  deriving Int -> TarDirDoesNotExist -> FilePath -> FilePath
[TarDirDoesNotExist] -> FilePath -> FilePath
TarDirDoesNotExist -> FilePath
(Int -> TarDirDoesNotExist -> FilePath -> FilePath)
-> (TarDirDoesNotExist -> FilePath)
-> ([TarDirDoesNotExist] -> FilePath -> FilePath)
-> Show TarDirDoesNotExist
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> TarDirDoesNotExist -> FilePath -> FilePath
showsPrec :: Int -> TarDirDoesNotExist -> FilePath -> FilePath
$cshow :: TarDirDoesNotExist -> FilePath
show :: TarDirDoesNotExist -> FilePath
$cshowList :: [TarDirDoesNotExist] -> FilePath -> FilePath
showList :: [TarDirDoesNotExist] -> FilePath -> FilePath
Show

instance Pretty TarDirDoesNotExist where
  pPrint :: TarDirDoesNotExist -> Doc
pPrint (TarDirDoesNotExist TarDir
dir) =
    FilePath -> Doc
text FilePath
"Tar directory does not exist:" Doc -> Doc -> Doc
<+> TarDir -> Doc
forall a. Pretty a => a -> Doc
pPrint TarDir
dir

instance HFErrorProject TarDirDoesNotExist where
  eBase :: Proxy TarDirDoesNotExist -> Int
eBase Proxy TarDirDoesNotExist
_ = Int
190
  eDesc :: Proxy TarDirDoesNotExist -> FilePath
eDesc Proxy TarDirDoesNotExist
_ = FilePath
"The tar directory (e.g. inside an archive) does not exist"

-- | File digest verification failed.
data DigestError = DigestError FilePath Text Text
  deriving Int -> DigestError -> FilePath -> FilePath
[DigestError] -> FilePath -> FilePath
DigestError -> FilePath
(Int -> DigestError -> FilePath -> FilePath)
-> (DigestError -> FilePath)
-> ([DigestError] -> FilePath -> FilePath)
-> Show DigestError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> DigestError -> FilePath -> FilePath
showsPrec :: Int -> DigestError -> FilePath -> FilePath
$cshow :: DigestError -> FilePath
show :: DigestError -> FilePath
$cshowList :: [DigestError] -> FilePath -> FilePath
showList :: [DigestError] -> FilePath -> FilePath
Show

instance Pretty DigestError where
  pPrint :: DigestError -> Doc
pPrint (DigestError FilePath
fp Text
currentDigest Text
expectedDigest) =
    FilePath -> Doc
text FilePath
"Digest error for" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
fp FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
": expected")
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Text -> FilePath
T.unpack Text
expectedDigest) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"but got" Doc -> Doc -> Doc
<+> Text -> Doc
forall a. Pretty a => a -> Doc
pPrint Text
currentDigest Doc -> Doc -> Doc
<+> FilePath -> Doc
text
      FilePath
"\nConsider removing the file in case it's cached and try again."

instance HFErrorProject DigestError where
  eBase :: Proxy DigestError -> Int
eBase Proxy DigestError
_ = Int
200
  eDesc :: Proxy DigestError -> FilePath
eDesc Proxy DigestError
_ = FilePath
"File digest verification failed"

-- | File PGP verification failed.
data GPGError = forall xs . (ToVariantMaybe DownloadFailed xs, PopVariant DownloadFailed xs, Show (V xs), Pretty (V xs)) => GPGError (V xs)

deriving instance Show GPGError

instance Pretty GPGError where
  pPrint :: GPGError -> Doc
pPrint (GPGError V xs
reason) = FilePath -> Doc
text FilePath
"GPG verify failed:" Doc -> Doc -> Doc
<+> V xs -> Doc
forall a. Pretty a => a -> Doc
pPrint V xs
reason

instance HFErrorProject GPGError where
  eBase :: Proxy GPGError -> Int
eBase Proxy GPGError
_ = Int
210
  eDesc :: Proxy GPGError -> FilePath
eDesc Proxy GPGError
_ = FilePath
"File PGP verification failed"

-- | Unexpected HTTP status.
data HTTPStatusError = HTTPStatusError Int (M.Map (CI ByteString) ByteString)
  deriving Int -> HTTPStatusError -> FilePath -> FilePath
[HTTPStatusError] -> FilePath -> FilePath
HTTPStatusError -> FilePath
(Int -> HTTPStatusError -> FilePath -> FilePath)
-> (HTTPStatusError -> FilePath)
-> ([HTTPStatusError] -> FilePath -> FilePath)
-> Show HTTPStatusError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> HTTPStatusError -> FilePath -> FilePath
showsPrec :: Int -> HTTPStatusError -> FilePath -> FilePath
$cshow :: HTTPStatusError -> FilePath
show :: HTTPStatusError -> FilePath
$cshowList :: [HTTPStatusError] -> FilePath -> FilePath
showList :: [HTTPStatusError] -> FilePath -> FilePath
Show

instance Pretty HTTPStatusError where
  pPrint :: HTTPStatusError -> Doc
pPrint (HTTPStatusError Int
status Map (CI ByteString) ByteString
_) =
    FilePath -> Doc
text FilePath
"Unexpected HTTP status:" Doc -> Doc -> Doc
<+> Int -> Doc
forall a. Pretty a => a -> Doc
pPrint Int
status

instance HFErrorProject HTTPStatusError where
  eBase :: Proxy HTTPStatusError -> Int
eBase Proxy HTTPStatusError
_ = Int
220
  eDesc :: Proxy HTTPStatusError -> FilePath
eDesc Proxy HTTPStatusError
_ = FilePath
"Unexpected HTTP status error (e.g. during downloads)"

-- | Malformed headers.
data MalformedHeaders = MalformedHeaders Text
  deriving Int -> MalformedHeaders -> FilePath -> FilePath
[MalformedHeaders] -> FilePath -> FilePath
MalformedHeaders -> FilePath
(Int -> MalformedHeaders -> FilePath -> FilePath)
-> (MalformedHeaders -> FilePath)
-> ([MalformedHeaders] -> FilePath -> FilePath)
-> Show MalformedHeaders
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> MalformedHeaders -> FilePath -> FilePath
showsPrec :: Int -> MalformedHeaders -> FilePath -> FilePath
$cshow :: MalformedHeaders -> FilePath
show :: MalformedHeaders -> FilePath
$cshowList :: [MalformedHeaders] -> FilePath -> FilePath
showList :: [MalformedHeaders] -> FilePath -> FilePath
Show

instance Pretty MalformedHeaders where
  pPrint :: MalformedHeaders -> Doc
pPrint (MalformedHeaders Text
h) =
    FilePath -> Doc
text FilePath
"Headers are malformed: " Doc -> Doc -> Doc
<+> Text -> Doc
forall a. Pretty a => a -> Doc
pPrint Text
h

instance HFErrorProject MalformedHeaders where
  eBase :: Proxy MalformedHeaders -> Int
eBase Proxy MalformedHeaders
_ = Int
230
  eDesc :: Proxy MalformedHeaders -> FilePath
eDesc Proxy MalformedHeaders
_ = FilePath
"Malformed headers during download"

-- | Unexpected HTTP status.
data HTTPNotModified = HTTPNotModified Text
  deriving Int -> HTTPNotModified -> FilePath -> FilePath
[HTTPNotModified] -> FilePath -> FilePath
HTTPNotModified -> FilePath
(Int -> HTTPNotModified -> FilePath -> FilePath)
-> (HTTPNotModified -> FilePath)
-> ([HTTPNotModified] -> FilePath -> FilePath)
-> Show HTTPNotModified
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> HTTPNotModified -> FilePath -> FilePath
showsPrec :: Int -> HTTPNotModified -> FilePath -> FilePath
$cshow :: HTTPNotModified -> FilePath
show :: HTTPNotModified -> FilePath
$cshowList :: [HTTPNotModified] -> FilePath -> FilePath
showList :: [HTTPNotModified] -> FilePath -> FilePath
Show

instance Pretty HTTPNotModified where
  pPrint :: HTTPNotModified -> Doc
pPrint (HTTPNotModified Text
etag) =
    FilePath -> Doc
text FilePath
"Remote resource not modifed, etag was:" Doc -> Doc -> Doc
<+> Text -> Doc
forall a. Pretty a => a -> Doc
pPrint Text
etag

instance HFErrorProject HTTPNotModified where
  eBase :: Proxy HTTPNotModified -> Int
eBase Proxy HTTPNotModified
_ = Int
240
  eDesc :: Proxy HTTPNotModified -> FilePath
eDesc Proxy HTTPNotModified
_ = FilePath
"Not modified HTTP status error (e.g. during downloads)."

-- | The 'Location' header was expected during a 3xx redirect, but not found.
data NoLocationHeader = NoLocationHeader
  deriving Int -> NoLocationHeader -> FilePath -> FilePath
[NoLocationHeader] -> FilePath -> FilePath
NoLocationHeader -> FilePath
(Int -> NoLocationHeader -> FilePath -> FilePath)
-> (NoLocationHeader -> FilePath)
-> ([NoLocationHeader] -> FilePath -> FilePath)
-> Show NoLocationHeader
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoLocationHeader -> FilePath -> FilePath
showsPrec :: Int -> NoLocationHeader -> FilePath -> FilePath
$cshow :: NoLocationHeader -> FilePath
show :: NoLocationHeader -> FilePath
$cshowList :: [NoLocationHeader] -> FilePath -> FilePath
showList :: [NoLocationHeader] -> FilePath -> FilePath
Show

instance Pretty NoLocationHeader where
  pPrint :: NoLocationHeader -> Doc
pPrint NoLocationHeader
NoLocationHeader =
    FilePath -> Doc
text (Proxy NoLocationHeader -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy NoLocationHeader
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoLocationHeader))

instance HFErrorProject NoLocationHeader where
  eBase :: Proxy NoLocationHeader -> Int
eBase Proxy NoLocationHeader
_ = Int
250
  eDesc :: Proxy NoLocationHeader -> FilePath
eDesc Proxy NoLocationHeader
_ = FilePath
"The 'Location' header was expected during a 3xx redirect, but not found."

-- | Too many redirects.
data TooManyRedirs = TooManyRedirs
  deriving Int -> TooManyRedirs -> FilePath -> FilePath
[TooManyRedirs] -> FilePath -> FilePath
TooManyRedirs -> FilePath
(Int -> TooManyRedirs -> FilePath -> FilePath)
-> (TooManyRedirs -> FilePath)
-> ([TooManyRedirs] -> FilePath -> FilePath)
-> Show TooManyRedirs
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> TooManyRedirs -> FilePath -> FilePath
showsPrec :: Int -> TooManyRedirs -> FilePath -> FilePath
$cshow :: TooManyRedirs -> FilePath
show :: TooManyRedirs -> FilePath
$cshowList :: [TooManyRedirs] -> FilePath -> FilePath
showList :: [TooManyRedirs] -> FilePath -> FilePath
Show

instance Pretty TooManyRedirs where
  pPrint :: TooManyRedirs -> Doc
pPrint TooManyRedirs
TooManyRedirs =
    FilePath -> Doc
text (Proxy TooManyRedirs -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy TooManyRedirs
forall {k} (t :: k). Proxy t
Proxy :: Proxy TooManyRedirs))

instance HFErrorProject TooManyRedirs where
  eBase :: Proxy TooManyRedirs -> Int
eBase Proxy TooManyRedirs
_ = Int
260
  eDesc :: Proxy TooManyRedirs -> FilePath
eDesc Proxy TooManyRedirs
_ = FilePath
"Too many redirections."

-- | A patch could not be applied.
data PatchFailed = PatchFailed
  deriving Int -> PatchFailed -> FilePath -> FilePath
[PatchFailed] -> FilePath -> FilePath
PatchFailed -> FilePath
(Int -> PatchFailed -> FilePath -> FilePath)
-> (PatchFailed -> FilePath)
-> ([PatchFailed] -> FilePath -> FilePath)
-> Show PatchFailed
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> PatchFailed -> FilePath -> FilePath
showsPrec :: Int -> PatchFailed -> FilePath -> FilePath
$cshow :: PatchFailed -> FilePath
show :: PatchFailed -> FilePath
$cshowList :: [PatchFailed] -> FilePath -> FilePath
showList :: [PatchFailed] -> FilePath -> FilePath
Show

instance Pretty PatchFailed where
  pPrint :: PatchFailed -> Doc
pPrint PatchFailed
PatchFailed =
    FilePath -> Doc
text (Proxy PatchFailed -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy PatchFailed
forall {k} (t :: k). Proxy t
Proxy :: Proxy PatchFailed))

instance HFErrorProject PatchFailed where
  eBase :: Proxy PatchFailed -> Int
eBase Proxy PatchFailed
_ = Int
270
  eDesc :: Proxy PatchFailed -> FilePath
eDesc Proxy PatchFailed
_ = FilePath
"A patch could not be applied."

-- | The tool requirements could not be found.
data NoToolRequirements = NoToolRequirements
  deriving Int -> NoToolRequirements -> FilePath -> FilePath
[NoToolRequirements] -> FilePath -> FilePath
NoToolRequirements -> FilePath
(Int -> NoToolRequirements -> FilePath -> FilePath)
-> (NoToolRequirements -> FilePath)
-> ([NoToolRequirements] -> FilePath -> FilePath)
-> Show NoToolRequirements
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoToolRequirements -> FilePath -> FilePath
showsPrec :: Int -> NoToolRequirements -> FilePath -> FilePath
$cshow :: NoToolRequirements -> FilePath
show :: NoToolRequirements -> FilePath
$cshowList :: [NoToolRequirements] -> FilePath -> FilePath
showList :: [NoToolRequirements] -> FilePath -> FilePath
Show

instance Pretty NoToolRequirements where
  pPrint :: NoToolRequirements -> Doc
pPrint NoToolRequirements
NoToolRequirements =
    FilePath -> Doc
text (Proxy NoToolRequirements -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy NoToolRequirements
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoToolRequirements))

instance HFErrorProject NoToolRequirements where
  eBase :: Proxy NoToolRequirements -> Int
eBase Proxy NoToolRequirements
_ = Int
280
  eDesc :: Proxy NoToolRequirements -> FilePath
eDesc Proxy NoToolRequirements
_ = FilePath
"The Tool requirements could not be found."

data InvalidBuildConfig = InvalidBuildConfig Text
  deriving Int -> InvalidBuildConfig -> FilePath -> FilePath
[InvalidBuildConfig] -> FilePath -> FilePath
InvalidBuildConfig -> FilePath
(Int -> InvalidBuildConfig -> FilePath -> FilePath)
-> (InvalidBuildConfig -> FilePath)
-> ([InvalidBuildConfig] -> FilePath -> FilePath)
-> Show InvalidBuildConfig
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> InvalidBuildConfig -> FilePath -> FilePath
showsPrec :: Int -> InvalidBuildConfig -> FilePath -> FilePath
$cshow :: InvalidBuildConfig -> FilePath
show :: InvalidBuildConfig -> FilePath
$cshowList :: [InvalidBuildConfig] -> FilePath -> FilePath
showList :: [InvalidBuildConfig] -> FilePath -> FilePath
Show

instance Pretty InvalidBuildConfig where
  pPrint :: InvalidBuildConfig -> Doc
pPrint (InvalidBuildConfig Text
reason) =
    FilePath -> Doc
text FilePath
"The build config is invalid. Reason was:" Doc -> Doc -> Doc
<+> Text -> Doc
forall a. Pretty a => a -> Doc
pPrint Text
reason

instance HFErrorProject InvalidBuildConfig where
  eBase :: Proxy InvalidBuildConfig -> Int
eBase Proxy InvalidBuildConfig
_ = Int
290
  eDesc :: Proxy InvalidBuildConfig -> FilePath
eDesc Proxy InvalidBuildConfig
_ = FilePath
"The build config is invalid."

data NoToolVersionSet = NoToolVersionSet Tool
  deriving Int -> NoToolVersionSet -> FilePath -> FilePath
[NoToolVersionSet] -> FilePath -> FilePath
NoToolVersionSet -> FilePath
(Int -> NoToolVersionSet -> FilePath -> FilePath)
-> (NoToolVersionSet -> FilePath)
-> ([NoToolVersionSet] -> FilePath -> FilePath)
-> Show NoToolVersionSet
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoToolVersionSet -> FilePath -> FilePath
showsPrec :: Int -> NoToolVersionSet -> FilePath -> FilePath
$cshow :: NoToolVersionSet -> FilePath
show :: NoToolVersionSet -> FilePath
$cshowList :: [NoToolVersionSet] -> FilePath -> FilePath
showList :: [NoToolVersionSet] -> FilePath -> FilePath
Show

instance Pretty NoToolVersionSet where
  pPrint :: NoToolVersionSet -> Doc
pPrint (NoToolVersionSet Tool
tool) =
    FilePath -> Doc
text FilePath
"No version is set for tool" Doc -> Doc -> Doc
<+> Tool -> Doc
forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"."

instance HFErrorProject NoToolVersionSet where
  eBase :: Proxy NoToolVersionSet -> Int
eBase Proxy NoToolVersionSet
_ = Int
300
  eDesc :: Proxy NoToolVersionSet -> FilePath
eDesc Proxy NoToolVersionSet
_ = FilePath
"No version is set for tool (but was expected)."

data NoNetwork = NoNetwork
  deriving Int -> NoNetwork -> FilePath -> FilePath
[NoNetwork] -> FilePath -> FilePath
NoNetwork -> FilePath
(Int -> NoNetwork -> FilePath -> FilePath)
-> (NoNetwork -> FilePath)
-> ([NoNetwork] -> FilePath -> FilePath)
-> Show NoNetwork
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoNetwork -> FilePath -> FilePath
showsPrec :: Int -> NoNetwork -> FilePath -> FilePath
$cshow :: NoNetwork -> FilePath
show :: NoNetwork -> FilePath
$cshowList :: [NoNetwork] -> FilePath -> FilePath
showList :: [NoNetwork] -> FilePath -> FilePath
Show

instance Pretty NoNetwork where
  pPrint :: NoNetwork -> Doc
pPrint NoNetwork
NoNetwork =
    FilePath -> Doc
text (Proxy NoNetwork -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy NoNetwork
forall {k} (t :: k). Proxy t
Proxy :: Proxy NoNetwork))

instance HFErrorProject NoNetwork where
  eBase :: Proxy NoNetwork -> Int
eBase Proxy NoNetwork
_ = Int
310
  eDesc :: Proxy NoNetwork -> FilePath
eDesc Proxy NoNetwork
_ = FilePath
"A download was required or requested, but '--offline' was specified."

data HadrianNotFound = HadrianNotFound
  deriving Int -> HadrianNotFound -> FilePath -> FilePath
[HadrianNotFound] -> FilePath -> FilePath
HadrianNotFound -> FilePath
(Int -> HadrianNotFound -> FilePath -> FilePath)
-> (HadrianNotFound -> FilePath)
-> ([HadrianNotFound] -> FilePath -> FilePath)
-> Show HadrianNotFound
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> HadrianNotFound -> FilePath -> FilePath
showsPrec :: Int -> HadrianNotFound -> FilePath -> FilePath
$cshow :: HadrianNotFound -> FilePath
show :: HadrianNotFound -> FilePath
$cshowList :: [HadrianNotFound] -> FilePath -> FilePath
showList :: [HadrianNotFound] -> FilePath -> FilePath
Show

instance Pretty HadrianNotFound where
  pPrint :: HadrianNotFound -> Doc
pPrint HadrianNotFound
HadrianNotFound =
    FilePath -> Doc
text (Proxy HadrianNotFound -> FilePath
forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (Proxy HadrianNotFound
forall {k} (t :: k). Proxy t
Proxy :: Proxy HadrianNotFound))

instance HFErrorProject HadrianNotFound where
  eBase :: Proxy HadrianNotFound -> Int
eBase Proxy HadrianNotFound
_ = Int
320
  eDesc :: Proxy HadrianNotFound -> FilePath
eDesc Proxy HadrianNotFound
_ = FilePath
"Could not find Hadrian build files. Does this GHC version support Hadrian builds?"

data ToolShadowed = ToolShadowed
                       Tool
                       FilePath  -- shadow binary
                       FilePath  -- upgraded binary
                       Version   -- upgraded version
  deriving Int -> ToolShadowed -> FilePath -> FilePath
[ToolShadowed] -> FilePath -> FilePath
ToolShadowed -> FilePath
(Int -> ToolShadowed -> FilePath -> FilePath)
-> (ToolShadowed -> FilePath)
-> ([ToolShadowed] -> FilePath -> FilePath)
-> Show ToolShadowed
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> ToolShadowed -> FilePath -> FilePath
showsPrec :: Int -> ToolShadowed -> FilePath -> FilePath
$cshow :: ToolShadowed -> FilePath
show :: ToolShadowed -> FilePath
$cshowList :: [ToolShadowed] -> FilePath -> FilePath
showList :: [ToolShadowed] -> FilePath -> FilePath
Show

instance Pretty ToolShadowed where
  pPrint :: ToolShadowed -> Doc
pPrint (ToolShadowed Tool
tool FilePath
sh FilePath
up Version
_) =
    FilePath -> Doc
text (Tool -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow Tool
tool
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" is shadowed by "
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
sh
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
".\nThe upgrade will not be in effect, unless you remove "
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
sh
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"\nor make sure "
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath
takeDirectory FilePath
up
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" comes before "
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath
takeDirectory FilePath
sh
         FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
" in PATH."
         )

instance HFErrorProject ToolShadowed where
  eBase :: Proxy ToolShadowed -> Int
eBase Proxy ToolShadowed
_ = Int
330
  eDesc :: Proxy ToolShadowed -> FilePath
eDesc Proxy ToolShadowed
_ = FilePath
"A tool is shadowed in PATH."

-- | File content length verification failed.
data ContentLengthError = ContentLengthError (Maybe FilePath) (Maybe Integer) Integer
  deriving Int -> ContentLengthError -> FilePath -> FilePath
[ContentLengthError] -> FilePath -> FilePath
ContentLengthError -> FilePath
(Int -> ContentLengthError -> FilePath -> FilePath)
-> (ContentLengthError -> FilePath)
-> ([ContentLengthError] -> FilePath -> FilePath)
-> Show ContentLengthError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> ContentLengthError -> FilePath -> FilePath
showsPrec :: Int -> ContentLengthError -> FilePath -> FilePath
$cshow :: ContentLengthError -> FilePath
show :: ContentLengthError -> FilePath
$cshowList :: [ContentLengthError] -> FilePath -> FilePath
showList :: [ContentLengthError] -> FilePath -> FilePath
Show

instance Pretty ContentLengthError where
  pPrint :: ContentLengthError -> Doc
pPrint (ContentLengthError Maybe FilePath
Nothing Maybe Integer
Nothing Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length exceeded expected size:"
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Integer -> FilePath
forall a. Show a => a -> FilePath
show Integer
expectedSize)
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nConsider removing the file in case it's cached and try again."
  pPrint (ContentLengthError Maybe FilePath
Nothing (Just Integer
currentSize) Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length error. Expected"
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Integer -> FilePath
forall a. Show a => a -> FilePath
show Integer
expectedSize) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"but got" Doc -> Doc -> Doc
<+> Integer -> Doc
forall a. Pretty a => a -> Doc
pPrint Integer
currentSize Doc -> Doc -> Doc
<+> FilePath -> Doc
text
      FilePath
"\nConsider removing the file in case it's cached and try again."
  pPrint (ContentLengthError (Just FilePath
fp) (Just Integer
currentSize) Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length error for" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
fp FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
": expected")
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Integer -> FilePath
forall a. Show a => a -> FilePath
show Integer
expectedSize) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"but got" Doc -> Doc -> Doc
<+> Integer -> Doc
forall a. Pretty a => a -> Doc
pPrint Integer
currentSize Doc -> Doc -> Doc
<+> FilePath -> Doc
text
      FilePath
"\nConsider removing the file in case it's cached and try again."
  pPrint (ContentLengthError (Just FilePath
fp) Maybe Integer
Nothing Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length error for" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
fp FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
": expected")
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Integer -> FilePath
forall a. Show a => a -> FilePath
show Integer
expectedSize) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nConsider removing the file in case it's cached and try again."

instance Exception ContentLengthError

instance HFErrorProject ContentLengthError where
  eBase :: Proxy ContentLengthError -> Int
eBase Proxy ContentLengthError
_ = Int
340
  eDesc :: Proxy ContentLengthError -> FilePath
eDesc Proxy ContentLengthError
_ = FilePath
"File content length verification failed"

data DuplicateReleaseChannel = DuplicateReleaseChannel NewURLSource
  deriving Int -> DuplicateReleaseChannel -> FilePath -> FilePath
[DuplicateReleaseChannel] -> FilePath -> FilePath
DuplicateReleaseChannel -> FilePath
(Int -> DuplicateReleaseChannel -> FilePath -> FilePath)
-> (DuplicateReleaseChannel -> FilePath)
-> ([DuplicateReleaseChannel] -> FilePath -> FilePath)
-> Show DuplicateReleaseChannel
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> DuplicateReleaseChannel -> FilePath -> FilePath
showsPrec :: Int -> DuplicateReleaseChannel -> FilePath -> FilePath
$cshow :: DuplicateReleaseChannel -> FilePath
show :: DuplicateReleaseChannel -> FilePath
$cshowList :: [DuplicateReleaseChannel] -> FilePath -> FilePath
showList :: [DuplicateReleaseChannel] -> FilePath -> FilePath
Show

instance HFErrorProject DuplicateReleaseChannel where
  eBase :: Proxy DuplicateReleaseChannel -> Int
eBase Proxy DuplicateReleaseChannel
_ = Int
350
  eDesc :: Proxy DuplicateReleaseChannel -> FilePath
eDesc Proxy DuplicateReleaseChannel
_ = FilePath
"Duplicate release channel detected when adding new source.\nGiving up. You can use '--force' to remove and append the duplicate source (this may change order/semantics)."

instance Pretty DuplicateReleaseChannel where
  pPrint :: DuplicateReleaseChannel -> Doc
pPrint (DuplicateReleaseChannel NewURLSource
source) =
    FilePath -> Doc
text (FilePath -> Doc) -> FilePath -> Doc
forall a b. (a -> b) -> a -> b
$ FilePath
"Duplicate release channel detected when adding: \n  "
      FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> NewURLSource -> FilePath
forall a. Show a => a -> FilePath
show NewURLSource
source
      FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"\nGiving up. You can use '--force' to remove and append the duplicate source (this may change order/semantics)."

data UnsupportedSetupCombo = UnsupportedSetupCombo Architecture Platform
  deriving Int -> UnsupportedSetupCombo -> FilePath -> FilePath
[UnsupportedSetupCombo] -> FilePath -> FilePath
UnsupportedSetupCombo -> FilePath
(Int -> UnsupportedSetupCombo -> FilePath -> FilePath)
-> (UnsupportedSetupCombo -> FilePath)
-> ([UnsupportedSetupCombo] -> FilePath -> FilePath)
-> Show UnsupportedSetupCombo
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> UnsupportedSetupCombo -> FilePath -> FilePath
showsPrec :: Int -> UnsupportedSetupCombo -> FilePath -> FilePath
$cshow :: UnsupportedSetupCombo -> FilePath
show :: UnsupportedSetupCombo -> FilePath
$cshowList :: [UnsupportedSetupCombo] -> FilePath -> FilePath
showList :: [UnsupportedSetupCombo] -> FilePath -> FilePath
Show

instance Pretty UnsupportedSetupCombo where
  pPrint :: UnsupportedSetupCombo -> Doc
pPrint (UnsupportedSetupCombo Architecture
arch Platform
plat) =
    FilePath -> Doc
text FilePath
"Could not find a compatible setup combo for:" Doc -> Doc -> Doc
<+> Architecture -> Doc
forall a. Pretty a => a -> Doc
pPrint Architecture
arch Doc -> Doc -> Doc
<+> Platform -> Doc
forall a. Pretty a => a -> Doc
pPrint Platform
plat

instance HFErrorProject UnsupportedSetupCombo where
  eBase :: Proxy UnsupportedSetupCombo -> Int
eBase Proxy UnsupportedSetupCombo
_ = Int
360
  eDesc :: Proxy UnsupportedSetupCombo -> FilePath
eDesc Proxy UnsupportedSetupCombo
_ = FilePath
"Could not find a compatible setup combo"

    -------------------------
    --[ High-level errors ]--
    -------------------------

-- | A download failed. The underlying error is encapsulated.
data DownloadFailed = forall xs . (HFErrorProject (V xs), ToVariantMaybe DownloadFailed xs, PopVariant DownloadFailed xs, Show (V xs), Pretty (V xs)) => DownloadFailed (V xs)

instance Pretty DownloadFailed where
  pPrint :: DownloadFailed -> Doc
pPrint (DownloadFailed V xs
reason) =
    case V xs
reason of
      VMaybe (DownloadFailed
_ :: DownloadFailed) -> V xs -> Doc
forall a. Pretty a => a -> Doc
pPrint V xs
reason
      V xs
_ -> FilePath -> Doc
text FilePath
"Download failed:" Doc -> Doc -> Doc
<+> V xs -> Doc
forall a. Pretty a => a -> Doc
pPrint V xs
reason

deriving instance Show DownloadFailed

instance HFErrorProject DownloadFailed where
  eBase :: Proxy DownloadFailed -> Int
eBase Proxy DownloadFailed
_ = Int
5000
  eNum :: DownloadFailed -> Int
eNum (DownloadFailed V xs
xs) = Int
5000 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V xs -> Int
forall a. HFErrorProject a => a -> Int
eNum V xs
xs
  eDesc :: Proxy DownloadFailed -> FilePath
eDesc Proxy DownloadFailed
_ = FilePath
"A download failed."

data InstallSetError = forall xs1 xs2 . (Show (V xs1), Pretty (V xs1), HFErrorProject (V xs1), Show (V xs2), Pretty (V xs2), HFErrorProject (V xs2)) => InstallSetError (V xs1) (V xs2)

instance Pretty InstallSetError where
  pPrint :: InstallSetError -> Doc
pPrint (InstallSetError V xs1
reason1 V xs2
reason2) =
     FilePath -> Doc
text FilePath
"Both installation and setting the tool failed. Install error was:"
      Doc -> Doc -> Doc
<+> V xs1 -> Doc
forall a. Pretty a => a -> Doc
pPrint V xs1
reason1
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nSet error was:"
      Doc -> Doc -> Doc
<+> V xs2 -> Doc
forall a. Pretty a => a -> Doc
pPrint V xs2
reason2

deriving instance Show InstallSetError

instance HFErrorProject InstallSetError where
  eBase :: Proxy InstallSetError -> Int
eBase Proxy InstallSetError
_ = Int
7000
  -- will there be collisions?
  eNum :: InstallSetError -> Int
eNum (InstallSetError V xs1
xs1 V xs2
xs2) = Int
7000 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V xs1 -> Int
forall a. HFErrorProject a => a -> Int
eNum V xs1
xs1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V xs2 -> Int
forall a. HFErrorProject a => a -> Int
eNum V xs2
xs2
  eDesc :: Proxy InstallSetError -> FilePath
eDesc Proxy InstallSetError
_ = FilePath
"Installation or setting the tool failed."


-- | A test failed.
data TestFailed = forall es . (ToVariantMaybe TestFailed es, PopVariant TestFailed es, Pretty (V es), Show (V es), HFErrorProject (V es)) => TestFailed FilePath (V es)

instance Pretty TestFailed where
  pPrint :: TestFailed -> Doc
pPrint (TestFailed FilePath
path V es
reason) =
    case V es
reason of
      VMaybe (TestFailed
_ :: TestFailed) -> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason
      V es
_ -> FilePath -> Doc
text (FilePath
"The test failed. GHC test suite is fragile and non-portable. Please also check out the " FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath -> FilePath
linkEscapeCode FilePath
"issue tracker" FilePath
" https://gitlab.haskell.org/ghc/ghc/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=testsuite&label_name%5B%5D=packaging&first_page_size=20" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
".\nBuild dir was:") Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
path Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nReason was:" Doc -> Doc -> Doc
<+> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason

deriving instance Show TestFailed

instance HFErrorProject TestFailed where
  eBase :: Proxy TestFailed -> Int
eBase Proxy TestFailed
_ = Int
4000
  eNum :: TestFailed -> Int
eNum (TestFailed FilePath
_ V es
xs2) = Int
4000 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V es -> Int
forall a. HFErrorProject a => a -> Int
eNum V es
xs2
  eDesc :: Proxy TestFailed -> FilePath
eDesc Proxy TestFailed
_ = FilePath
"The test failed."

-- | A build failed.
data BuildFailed = forall es . (ToVariantMaybe BuildFailed es, PopVariant BuildFailed es, Pretty (V es), Show (V es), HFErrorProject (V es)) => BuildFailed FilePath (V es)

instance Pretty BuildFailed where
  pPrint :: BuildFailed -> Doc
pPrint (BuildFailed FilePath
path V es
reason) =
    case V es
reason of
      VMaybe (BuildFailed
_ :: BuildFailed) -> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason
      V es
_ -> FilePath -> Doc
text FilePath
"BuildFailed failed in dir" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
path FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
":") Doc -> Doc -> Doc
<+> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason

deriving instance Show BuildFailed

instance HFErrorProject BuildFailed where
  eBase :: Proxy BuildFailed -> Int
eBase Proxy BuildFailed
_ = Int
8000
  eNum :: BuildFailed -> Int
eNum (BuildFailed FilePath
_ V es
xs2) = Int
8000 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V es -> Int
forall a. HFErrorProject a => a -> Int
eNum V es
xs2
  eDesc :: Proxy BuildFailed -> FilePath
eDesc Proxy BuildFailed
_ = FilePath
"The build failed."


-- | Setting the current GHC version failed.
data GHCupSetError = forall es . (ToVariantMaybe GHCupSetError es, PopVariant GHCupSetError es, Show (V es), Pretty (V es), HFErrorProject (V es)) => GHCupSetError (V es)

instance Pretty GHCupSetError where
  pPrint :: GHCupSetError -> Doc
pPrint (GHCupSetError V es
reason) =
    case V es
reason of
      VMaybe (GHCupSetError
_ :: GHCupSetError) -> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason
      V es
_ -> FilePath -> Doc
text FilePath
"Setting the current version failed:" Doc -> Doc -> Doc
<+> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason

deriving instance Show GHCupSetError

instance HFErrorProject GHCupSetError where
  eBase :: Proxy GHCupSetError -> Int
eBase Proxy GHCupSetError
_ = Int
9000
  eNum :: GHCupSetError -> Int
eNum (GHCupSetError V es
xs) = Int
9000 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V es -> Int
forall a. HFErrorProject a => a -> Int
eNum V es
xs
  eDesc :: Proxy GHCupSetError -> FilePath
eDesc Proxy GHCupSetError
_ = FilePath
"Setting the current version failed."

-- | Executing stacks platform detection failed.
data StackPlatformDetectError = forall es . (ToVariantMaybe StackPlatformDetectError es, PopVariant StackPlatformDetectError es, Show (V es), Pretty (V es), HFErrorProject (V es)) => StackPlatformDetectError (V es)

instance Pretty StackPlatformDetectError where
  pPrint :: StackPlatformDetectError -> Doc
pPrint (StackPlatformDetectError V es
reason) =
    case V es
reason of
      VMaybe (StackPlatformDetectError
_ :: StackPlatformDetectError) -> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason
      V es
_ -> FilePath -> Doc
text FilePath
"Running stack platform detection logic failed:" Doc -> Doc -> Doc
<+> V es -> Doc
forall a. Pretty a => a -> Doc
pPrint V es
reason

deriving instance Show StackPlatformDetectError

instance HFErrorProject StackPlatformDetectError where
  eBase :: Proxy StackPlatformDetectError -> Int
eBase Proxy StackPlatformDetectError
_ = Int
6000
  eNum :: StackPlatformDetectError -> Int
eNum (StackPlatformDetectError V es
xs) = Int
6000 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ V es -> Int
forall a. HFErrorProject a => a -> Int
eNum V es
xs
  eDesc :: Proxy StackPlatformDetectError -> FilePath
eDesc Proxy StackPlatformDetectError
_ = FilePath
"Running stack platform detection logic failed."


    ---------------------------------------------
    --[ True Exceptions (e.g. for MonadThrow) ]--
    ---------------------------------------------


-- | Parsing failed.
data ParseError = ParseError String
  deriving Int -> ParseError -> FilePath -> FilePath
[ParseError] -> FilePath -> FilePath
ParseError -> FilePath
(Int -> ParseError -> FilePath -> FilePath)
-> (ParseError -> FilePath)
-> ([ParseError] -> FilePath -> FilePath)
-> Show ParseError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> ParseError -> FilePath -> FilePath
showsPrec :: Int -> ParseError -> FilePath -> FilePath
$cshow :: ParseError -> FilePath
show :: ParseError -> FilePath
$cshowList :: [ParseError] -> FilePath -> FilePath
showList :: [ParseError] -> FilePath -> FilePath
Show

instance Pretty ParseError where
  pPrint :: ParseError -> Doc
pPrint (ParseError FilePath
reason) =
    FilePath -> Doc
text FilePath
"Parsing failed:" Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
reason

instance Exception ParseError

instance HFErrorProject ParseError where
  eBase :: Proxy ParseError -> Int
eBase Proxy ParseError
_ = Int
500
  eDesc :: Proxy ParseError -> FilePath
eDesc Proxy ParseError
_ = FilePath
"A parse error occured."


data UnexpectedListLength = UnexpectedListLength String
  deriving Int -> UnexpectedListLength -> FilePath -> FilePath
[UnexpectedListLength] -> FilePath -> FilePath
UnexpectedListLength -> FilePath
(Int -> UnexpectedListLength -> FilePath -> FilePath)
-> (UnexpectedListLength -> FilePath)
-> ([UnexpectedListLength] -> FilePath -> FilePath)
-> Show UnexpectedListLength
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> UnexpectedListLength -> FilePath -> FilePath
showsPrec :: Int -> UnexpectedListLength -> FilePath -> FilePath
$cshow :: UnexpectedListLength -> FilePath
show :: UnexpectedListLength -> FilePath
$cshowList :: [UnexpectedListLength] -> FilePath -> FilePath
showList :: [UnexpectedListLength] -> FilePath -> FilePath
Show

instance Pretty UnexpectedListLength where
  pPrint :: UnexpectedListLength -> Doc
pPrint (UnexpectedListLength FilePath
reason) =
    FilePath -> Doc
text FilePath
"List length unexpected:" Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
reason

instance Exception UnexpectedListLength

instance HFErrorProject UnexpectedListLength where
  eBase :: Proxy UnexpectedListLength -> Int
eBase Proxy UnexpectedListLength
_ = Int
510
  eDesc :: Proxy UnexpectedListLength -> FilePath
eDesc Proxy UnexpectedListLength
_ = FilePath
"A list had an unexpected length."

data NoUrlBase = NoUrlBase Text
  deriving Int -> NoUrlBase -> FilePath -> FilePath
[NoUrlBase] -> FilePath -> FilePath
NoUrlBase -> FilePath
(Int -> NoUrlBase -> FilePath -> FilePath)
-> (NoUrlBase -> FilePath)
-> ([NoUrlBase] -> FilePath -> FilePath)
-> Show NoUrlBase
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> NoUrlBase -> FilePath -> FilePath
showsPrec :: Int -> NoUrlBase -> FilePath -> FilePath
$cshow :: NoUrlBase -> FilePath
show :: NoUrlBase -> FilePath
$cshowList :: [NoUrlBase] -> FilePath -> FilePath
showList :: [NoUrlBase] -> FilePath -> FilePath
Show

instance Pretty NoUrlBase where
  pPrint :: NoUrlBase -> Doc
pPrint (NoUrlBase Text
url) =
    FilePath -> Doc
text FilePath
"Couldn't get a base filename from url" Doc -> Doc -> Doc
<+> Text -> Doc
forall a. Pretty a => a -> Doc
pPrint Text
url

instance Exception NoUrlBase

instance HFErrorProject NoUrlBase where
  eBase :: Proxy NoUrlBase -> Int
eBase Proxy NoUrlBase
_ = Int
520
  eDesc :: Proxy NoUrlBase -> FilePath
eDesc Proxy NoUrlBase
_ = FilePath
"URL does not have a base filename."

data DigestMissing = DigestMissing URI
  deriving Int -> DigestMissing -> FilePath -> FilePath
[DigestMissing] -> FilePath -> FilePath
DigestMissing -> FilePath
(Int -> DigestMissing -> FilePath -> FilePath)
-> (DigestMissing -> FilePath)
-> ([DigestMissing] -> FilePath -> FilePath)
-> Show DigestMissing
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> DigestMissing -> FilePath -> FilePath
showsPrec :: Int -> DigestMissing -> FilePath -> FilePath
$cshow :: DigestMissing -> FilePath
show :: DigestMissing -> FilePath
$cshowList :: [DigestMissing] -> FilePath -> FilePath
showList :: [DigestMissing] -> FilePath -> FilePath
Show

instance Pretty DigestMissing where
  pPrint :: DigestMissing -> Doc
pPrint (DigestMissing URI
uri) =
    FilePath -> Doc
text FilePath
"Digest missing for:" Doc -> Doc -> Doc
<+> (FilePath -> Doc
text (FilePath -> Doc) -> (URI -> FilePath) -> URI -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> FilePath
T.unpack (Text -> FilePath) -> (URI -> Text) -> URI -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OnDecodeError -> ByteString -> Text
E.decodeUtf8With OnDecodeError
E.lenientDecode (ByteString -> Text) -> (URI -> ByteString) -> URI -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> ByteString
forall a. URIRef a -> ByteString
serializeURIRef') URI
uri

instance Exception DigestMissing

instance HFErrorProject DigestMissing where
  eBase :: Proxy DigestMissing -> Int
eBase Proxy DigestMissing
_ = Int
530
  eDesc :: Proxy DigestMissing -> FilePath
eDesc Proxy DigestMissing
_ = FilePath
"An expected digest is missing."


    ------------------------
    --[ orphan instances ]--
    ------------------------

instance Pretty (V '[]) where
   {-# INLINABLE pPrint #-}
   pPrint :: V '[] -> Doc
pPrint V '[]
_ = Doc
forall a. HasCallStack => a
undefined

instance
   ( Pretty x
   , Pretty (V xs)
   ) => Pretty (V (x ': xs))
   where
      pPrint :: V (x : xs) -> Doc
pPrint V (x : xs)
v = case V (x : xs) -> Either (V xs) x
forall x (xs :: [*]). V (x : xs) -> Either (V xs) x
popVariantHead V (x : xs)
v of
         Right x
x -> x -> Doc
forall a. Pretty a => a -> Doc
pPrint x
x
         Left V xs
xs -> V xs -> Doc
forall a. Pretty a => a -> Doc
pPrint V xs
xs

instance HFErrorProject (V '[]) where
   {-# INLINABLE eBase #-}
   eBase :: Proxy (V '[]) -> Int
eBase Proxy (V '[])
_ = Int
forall a. HasCallStack => a
undefined
   {-# INLINABLE eDesc #-}
   eDesc :: Proxy (V '[]) -> FilePath
eDesc Proxy (V '[])
_ = FilePath
forall a. HasCallStack => a
undefined

instance
   ( HFErrorProject x
   , HFErrorProject (V xs)
   ) => HFErrorProject (V (x ': xs))
   where
      eNum :: V (x : xs) -> Int
eNum V (x : xs)
v = case V (x : xs) -> Either (V xs) x
forall x (xs :: [*]). V (x : xs) -> Either (V xs) x
popVariantHead V (x : xs)
v of
         Right x
x -> x -> Int
forall a. HFErrorProject a => a -> Int
eNum x
x
         Left V xs
xs -> V xs -> Int
forall a. HFErrorProject a => a -> Int
eNum V xs
xs
      eDesc :: Proxy (V (x : xs)) -> FilePath
eDesc Proxy (V (x : xs))
_ = FilePath
forall a. HasCallStack => a
undefined
      eBase :: Proxy (V (x : xs)) -> Int
eBase Proxy (V (x : xs))
_ = Int
forall a. HasCallStack => a
undefined

instance Pretty URIParseError where
  pPrint :: URIParseError -> Doc
pPrint (MalformedScheme SchemaError
reason) =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed scheme:" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (SchemaError -> FilePath
forall a. Show a => a -> FilePath
show SchemaError
reason)
  pPrint URIParseError
MalformedUserInfo =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed user info."
  pPrint URIParseError
MalformedQuery =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed query."
  pPrint URIParseError
MalformedFragment =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed fragment."
  pPrint URIParseError
MalformedHost =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed host."
  pPrint URIParseError
MalformedPort =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed port."
  pPrint URIParseError
MalformedPath =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed path."
  pPrint (OtherError FilePath
err) =
    FilePath -> Doc
text FilePath
"Failed to parse URI:" Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
err

instance HFErrorProject URIParseError where
  eBase :: Proxy URIParseError -> Int
eBase Proxy URIParseError
_ = Int
800

  eNum :: URIParseError -> Int
eNum (MalformedScheme SchemaError
NonAlphaLeading) = Int
801
  eNum (MalformedScheme SchemaError
InvalidChars) = Int
802
  eNum (MalformedScheme SchemaError
MissingColon) = Int
803
  eNum URIParseError
MalformedUserInfo   = Int
804
  eNum URIParseError
MalformedQuery      = Int
805
  eNum URIParseError
MalformedFragment   = Int
806
  eNum URIParseError
MalformedHost       = Int
807
  eNum URIParseError
MalformedPort       = Int
808
  eNum URIParseError
MalformedPath       = Int
809
  eNum (OtherError FilePath
_)      = Int
810

  eDesc :: Proxy URIParseError -> FilePath
eDesc Proxy URIParseError
_ = FilePath
"Failed to parse URI."

instance Pretty ArchiveResult where
  pPrint :: ArchiveResult -> Doc
pPrint ArchiveResult
ArchiveFatal = FilePath -> Doc
text FilePath
"Archive result: fatal"
  pPrint ArchiveResult
ArchiveFailed = FilePath -> Doc
text FilePath
"Archive result: failed"
  pPrint ArchiveResult
ArchiveWarn = FilePath -> Doc
text FilePath
"Archive result: warning"
  pPrint ArchiveResult
ArchiveRetry = FilePath -> Doc
text FilePath
"Archive result: retry"
  pPrint ArchiveResult
ArchiveOk = FilePath -> Doc
text FilePath
"Archive result: Ok"
  pPrint ArchiveResult
ArchiveEOF = FilePath -> Doc
text FilePath
"Archive result: EOF"

instance HFErrorProject ArchiveResult where
  eBase :: Proxy ArchiveResult -> Int
eBase Proxy ArchiveResult
_ = Int
820

  eNum :: ArchiveResult -> Int
eNum ArchiveResult
ArchiveFatal  = Int
821
  eNum ArchiveResult
ArchiveFailed = Int
822
  eNum ArchiveResult
ArchiveWarn   = Int
823
  eNum ArchiveResult
ArchiveRetry  = Int
824
  eNum ArchiveResult
ArchiveOk     = Int
825
  eNum ArchiveResult
ArchiveEOF    = Int
826

  eDesc :: Proxy ArchiveResult -> FilePath
eDesc Proxy ArchiveResult
_ = FilePath
"Archive extraction result."

instance Pretty T.Text where
  pPrint :: Text -> Doc
pPrint = FilePath -> Doc
text (FilePath -> Doc) -> (Text -> FilePath) -> Text -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> FilePath
T.unpack

instance Pretty ProcessError where
  pPrint :: ProcessError -> Doc
pPrint (NonZeroExit Int
e FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Process" Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"with arguments" Doc -> Doc -> Doc
<+> [FilePath] -> Doc
forall a. Pretty a => a -> Doc
pPrint [FilePath]
args Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"failed with exit code" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Int -> FilePath
forall a. Show a => a -> FilePath
show Int
e FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
".")
  pPrint (PTerminated FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Process" Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"with arguments" Doc -> Doc -> Doc
<+> [FilePath] -> Doc
forall a. Pretty a => a -> Doc
pPrint [FilePath]
args Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"terminated."
  pPrint (PStopped FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Process" Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"with arguments" Doc -> Doc -> Doc
<+> [FilePath] -> Doc
forall a. Pretty a => a -> Doc
pPrint [FilePath]
args Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"stopped."
  pPrint (NoSuchPid FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Could not find PID for process running " Doc -> Doc -> Doc
<+> FilePath -> Doc
forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
" with arguments " Doc -> Doc -> Doc
<+> FilePath -> Doc
text ([FilePath] -> FilePath
forall a. Show a => a -> FilePath
show [FilePath]
args) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"."

instance HFErrorProject ProcessError where
  eBase :: Proxy ProcessError -> Int
eBase Proxy ProcessError
_ = Int
840

  eNum :: ProcessError -> Int
eNum NonZeroExit{}     = Int
841
  eNum (PTerminated FilePath
_ [FilePath]
_) = Int
842
  eNum (PStopped FilePath
_ [FilePath]
_)    = Int
843
  eNum (NoSuchPid FilePath
_ [FilePath]
_)   = Int
844

  eDesc :: Proxy ProcessError -> FilePath
eDesc Proxy ProcessError
_ = FilePath
"A process exited prematurely."