-
Notifications
You must be signed in to change notification settings - Fork 21
/
Error.hs
63 lines (55 loc) · 3.11 KB
/
Error.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{-# LANGUAGE DeriveDataTypeable #-}
module Error (HackPortError(..), throwEx, catchEx, hackPortShowError) where
import Data.Typeable
import Control.Exception.Extensible as EE
import Control.Monad.Error
data HackPortError
= ArgumentError String
| ConnectionFailed String String
| PackageNotFound String
| InvalidTarballURL String String
| InvalidSignatureURL String String
| VerificationFailed String String
| DownloadFailed String String
| UnknownCompression String
| UnpackingFailed String Int
| NoCabalFound String
| ExtractionFailed String String Int
| CabalParseFailed String String
| BashNotFound
| BashError String
| NoOverlay
| MultipleOverlays [String]
| UnknownVerbosityLevel String
-- | WrongCacheVersion
-- | InvalidCache
| InvalidServer String
deriving (Typeable, Show)
instance Error HackPortError where
instance Exception HackPortError where
throwEx :: HackPortError -> IO a
throwEx = EE.throw
catchEx :: IO a -> (HackPortError -> IO a) -> IO a
catchEx = EE.catch
hackPortShowError :: HackPortError -> String
hackPortShowError err = case err of
ArgumentError str -> "Argument error: "++str
ConnectionFailed server reason -> "Connection to hackage server '"++server++"' failed: "++reason
PackageNotFound pkg -> "Package '"++ pkg ++"' not found on server. Try 'hackport update'?"
InvalidTarballURL url reason -> "Error while downloading tarball '"++url++"': "++reason
InvalidSignatureURL url reason -> "Error while downloading signature '"++url++"': "++reason
VerificationFailed file signature -> "Error while checking signature('"++signature++"') of '"++file++"'"
DownloadFailed url reason -> "Error while downloading '"++url++"': "++reason
UnknownCompression tarball -> "Couldn't guess compression type of '"++tarball++"'"
UnpackingFailed tarball code -> "Unpacking '"++tarball++"' failed with exit code '"++show code++"'"
NoCabalFound tarball -> "Tarball '"++tarball++"' doesn't contain a cabal file"
ExtractionFailed tarball file code -> "Extracting '"++file++"' from '"++tarball++"' failed with '"++show code++"'"
CabalParseFailed file reason -> "Error while parsing cabal file '"++file++"': "++reason
BashNotFound -> "The 'bash' executable was not found. It is required to figure out your portage-overlay. If you don't want to install bash, use '-p path-to-overlay'"
BashError str -> "Error while guessing your portage-overlay. Either set PORTDIR_OVERLAY in /etc/make.conf or use '-p path-to-overlay'.\nThe error was: \""++str++"\""
MultipleOverlays overlays -> "You have the following overlays available: '"++unwords overlays++"'. Please choose one by using 'hackport -p path-to-overlay' <command>"
NoOverlay -> "You don't have PORTDIR_OVERLAY set in '/etc/make.conf'. Please set it or use '-p path-to-overlay'"
UnknownVerbosityLevel str -> "The verbosity level '"++str++"' is invalid. Please use debug,normal or silent"
InvalidServer srv -> "Invalid server address, could not parse: " ++ srv
--WrongCacheVersion -> "The version of the cache is too old. Please update the cache using 'hackport update'"
--InvalidCache -> "Could not read the cache. Please ensure that it's up to date using 'hackport update'"