aboutsummaryrefslogtreecommitdiffstats
path: root/app/Exception.hs
blob: 6ac243b6bce1341e9d002248376086dfd9cb1584 (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
module Exception
  ( AnyException (..),
    InvalidTreeGrepperResult (..),
    NoCommits (..),
    ProcessException (..),
    UnknownFile (..),
    InvalidDiff (..),
    InvalidIssue (..),
    CannotReadFile (..),
    UnsupportedLanguage (..),
    NoAncestor (..),
  )
where

import CMark qualified as D
import Control.Exception
import Data.ByteString.Lazy.Char8 as LB
import Data.Text qualified as T
import Data.Void (Void)
import Git.CommitHash qualified as Git
import System.Exit (ExitCode)
import Text.Megaparsec qualified as P

data AnyException
  = InvalidTreeGrepperResult' InvalidTreeGrepperResult
  | NoCommits' NoCommits
  | ProcessException' ProcessException
  | UnknownFile' UnknownFile
  | InvalidDiff' InvalidDiff
  | InvalidIssue' InvalidIssue
  | UnsupportedLanguage' UnsupportedLanguage
  | NoAncestor' NoAncestor
  deriving (Show)

instance Exception AnyException

data InvalidTreeGrepperResult = InvalidTreeGrepperResult
  { error :: String
  }
  deriving (Show)

instance Exception InvalidTreeGrepperResult

data NoCommits = NoCommits
  deriving (Show)

instance Exception NoCommits

data ProcessException = ProcessException String ExitCode LB.ByteString
  deriving (Show)

instance Exception ProcessException

data UnknownFile = UnknownFile
  { filePath :: FilePath
  }
  deriving (Show)

instance Exception UnknownFile

data InvalidDiff = InvalidDiff String
  deriving (Show)

instance Exception InvalidDiff

data InvalidIssue = InvalidIssue (P.ParseErrorBundle [D.Node] Void)
  deriving (Show)

instance Exception InvalidIssue

data CannotReadFile = CannotReadFile FilePath
  deriving (Show)

instance Exception CannotReadFile

data UnsupportedLanguage = UnsupportedLanguage T.Text
  deriving (Show)

instance Exception UnsupportedLanguage

data NoAncestor = NoAncestor Git.CommitHash Git.CommitHash
  deriving (Show)

instance Exception NoAncestor