1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Error where
5import Data.Aeson ((.=))
6import qualified Data.Aeson as Json
7import Prelude hiding (print)
9import qualified Reporting.Annotation as A
10import qualified Reporting.Error.Canonicalize as Canonicalize
11import qualified Reporting.Error.Docs as Docs
12import qualified Reporting.Error.Pattern as Pattern
13import qualified Reporting.Error.Syntax as Syntax
14import qualified Reporting.Error.Type as Type
15import qualified Reporting.Render.Type as RenderType
16import qualified Reporting.Report as Report
23 | Canonicalize Canonicalize.Error
25 | Pattern Pattern.Error
31toReport :: RenderType.Localizer -> Error -> Report.Report
32toReport localizer err =
35 Syntax.toReport localizer syntaxError
37 Canonicalize canonicalizeError ->
38 Canonicalize.toReport localizer canonicalizeError
41 Type.toReport localizer typeError
43 Pattern patternError ->
44 Pattern.toReport localizer patternError
47 Docs.toReport docsError
52toString :: RenderType.Localizer -> String -> String -> A.Located Error -> String
53toString localizer location source (A.A region err) =
54 Report.toString location region (toReport localizer err) source
57print :: RenderType.Localizer -> String -> String -> A.Located Error -> IO ()
58print localizer location source (A.A region err) =
59 Report.printError location region (toReport localizer err) source
64toJson :: RenderType.Localizer -> FilePath -> A.Located Error -> Json.Value
65toJson localizer filePath (A.A region err) =
67 (maybeRegion, additionalFields) =
70 Report.toJson [] (Syntax.toReport localizer syntaxError)
72 Canonicalize canonicalizeError ->
76 (\s -> ["suggestions" .= s])
77 (Canonicalize.extractSuggestions canonicalizeError)
79 Report.toJson suggestions (Canonicalize.toReport localizer canonicalizeError)
82 Report.toJson [] (Type.toReport localizer typeError)
84 Pattern patternError ->
85 Report.toJson [] (Pattern.toReport localizer patternError)
88 Report.toJson [] (Docs.toReport docsError)
93 , "subregion" .= maybeRegion
94 , "type" .= ("error" :: String)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list