2020-01-11 20:15:05 +00:00
|
|
|
{-# LANGUAGE ExistentialQuantification #-}
|
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE StandaloneDeriving #-}
|
|
|
|
{-# LANGUAGE DataKinds #-}
|
|
|
|
|
2020-07-21 23:08:58 +00:00
|
|
|
{-|
|
|
|
|
Module : GHCup.Errors
|
|
|
|
Description : GHCup error types
|
|
|
|
Copyright : (c) Julian Ospald, 2020
|
2020-07-30 18:04:02 +00:00
|
|
|
License : LGPL-3.0
|
2020-07-21 23:08:58 +00:00
|
|
|
Maintainer : hasufell@hasufell.de
|
|
|
|
Stability : experimental
|
|
|
|
Portability : POSIX
|
|
|
|
-}
|
2020-01-11 20:15:05 +00:00
|
|
|
module GHCup.Errors where
|
|
|
|
|
|
|
|
import GHCup.Types
|
|
|
|
|
|
|
|
import Control.Exception.Safe
|
|
|
|
import Data.ByteString ( ByteString )
|
|
|
|
import Data.Text ( Text )
|
|
|
|
import Data.Versions
|
|
|
|
import Haskus.Utils.Variant
|
|
|
|
import HPath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
------------------------
|
|
|
|
--[ Low-level errors ]--
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- | A compatible platform could not be found.
|
|
|
|
data NoCompatiblePlatform = NoCompatiblePlatform String -- the platform we got
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | Unable to find a download for the requested versio/distro.
|
|
|
|
data NoDownload = NoDownload
|
|
|
|
deriving Show
|
|
|
|
|
2020-04-15 11:57:44 +00:00
|
|
|
-- | No update available or necessary.
|
|
|
|
data NoUpdate = NoUpdate
|
|
|
|
deriving Show
|
|
|
|
|
2020-01-11 20:15:05 +00:00
|
|
|
-- | The Architecture is unknown and unsupported.
|
|
|
|
data NoCompatibleArch = NoCompatibleArch String
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | Unable to figure out the distribution of the host.
|
|
|
|
data DistroNotFound = DistroNotFound
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | The archive format is unknown. We don't know how to extract it.
|
|
|
|
data UnknownArchive = UnknownArchive ByteString
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | The scheme is not supported (such as ftp).
|
|
|
|
data UnsupportedScheme = UnsupportedScheme
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | Unable to copy a file.
|
|
|
|
data CopyError = CopyError String
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | Unable to find a tag of a tool.
|
|
|
|
data TagNotFound = TagNotFound Tag Tool
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | The tool (such as GHC) is already installed with that version.
|
|
|
|
data AlreadyInstalled = AlreadyInstalled Tool Version
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | The tool is not installed. Some operations rely on a tool
|
|
|
|
-- to be installed (such as setting the current GHC version).
|
2020-04-25 10:06:41 +00:00
|
|
|
data NotInstalled = NotInstalled Tool Text
|
2020-01-11 20:15:05 +00:00
|
|
|
deriving Show
|
|
|
|
|
2020-04-10 20:44:43 +00:00
|
|
|
-- | An executable was expected to be in PATH, but was not found.
|
|
|
|
data NotFoundInPATH = NotFoundInPATH (Path Rel)
|
|
|
|
deriving Show
|
|
|
|
|
2020-01-11 20:15:05 +00:00
|
|
|
-- | JSON decoding failed.
|
|
|
|
data JSONError = JSONDecodeError String
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | A file that is supposed to exist does not exist
|
|
|
|
-- (e.g. when we use file scheme to "download" something).
|
|
|
|
data FileDoesNotExistError = FileDoesNotExistError ByteString
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | File digest verification failed.
|
|
|
|
data DigestError = DigestError Text Text
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | Unexpected HTTP status.
|
|
|
|
data HTTPStatusError = HTTPStatusError Int
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | The 'Location' header was expected during a 3xx redirect, but not found.
|
|
|
|
data NoLocationHeader = NoLocationHeader
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
-- | Too many redirects.
|
|
|
|
data TooManyRedirs = TooManyRedirs
|
|
|
|
deriving Show
|
|
|
|
|
2020-04-08 20:57:57 +00:00
|
|
|
-- | A patch could not be applied.
|
|
|
|
data PatchFailed = PatchFailed
|
|
|
|
deriving Show
|
|
|
|
|
2020-04-10 15:36:27 +00:00
|
|
|
-- | The tool requirements could not be found.
|
|
|
|
data NoToolRequirements = NoToolRequirements
|
|
|
|
deriving Show
|
2020-01-11 20:15:05 +00:00
|
|
|
|
2020-04-25 10:06:41 +00:00
|
|
|
data InvalidBuildConfig = InvalidBuildConfig Text
|
|
|
|
deriving Show
|
|
|
|
|
2020-01-11 20:15:05 +00:00
|
|
|
|
|
|
|
-------------------------
|
|
|
|
--[ High-level errors ]--
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
-- | A download failed. The underlying error is encapsulated.
|
|
|
|
data DownloadFailed = forall es . Show (V es) => DownloadFailed (V es)
|
|
|
|
|
|
|
|
deriving instance Show DownloadFailed
|
|
|
|
|
|
|
|
|
|
|
|
-- | A build failed.
|
|
|
|
data BuildFailed = forall es . Show (V es) => BuildFailed (Path Abs) (V es)
|
|
|
|
|
|
|
|
deriving instance Show BuildFailed
|
|
|
|
|
|
|
|
|
|
|
|
-- | Setting the current GHC version failed.
|
|
|
|
data GHCupSetError = forall es . Show (V es) => GHCupSetError (V es)
|
|
|
|
|
|
|
|
deriving instance Show GHCupSetError
|
|
|
|
|
|
|
|
|
|
|
|
---------------------------------------------
|
|
|
|
--[ True Exceptions (e.g. for MonadThrow) ]--
|
|
|
|
---------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
-- | Parsing failed.
|
|
|
|
data ParseError = ParseError String
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
instance Exception ParseError
|