on master help sign in
Move JSON errors to Reporting.Error
commit137338801effc3d4a0960370f306ebd333aa3235 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 27 Dec 2018, 11:08 (8 years ago) parenta66a03f
1 file changed+82−13
compiler/src/Json/Decode/Error.hs → compiler/src/Reporting/Error/Json.hs+82−13
compiler/src/Json/Decode/Error.hs → compiler/src/Reporting/Error/Json.hsrenamed+82−13
@@ -1,23 +1,20 @@
1+{-# OPTIONS_GHC -Wall #-}
12{-# LANGUAGE OverloadedStrings #-}
2−module Json.Decode.Error
3+module Reporting.Error.Json
34 ( Error(..)
4− , toDoc
5+ , Problem(..)
6+ , DecodeExpectation(..)
7+ , ParseExpectation(..)
8+ , Context(..)
9+ , toReport
510 )
611 where
712
813
9−import Prelude hiding (userError)
10−import qualified Data.Char as Char
11−import qualified Data.List as List
12−import qualified Data.Map as Map
13−import qualified Data.Text as Text
14+import qualified Data.Utf8 as Utf8
15+import Data.Word (Word16)
1416
15−import qualified Json.Decode.Internals as Json
16−import qualified Json.Encode as E
17−import Reporting.Doc ((<+>), (<>))
18−import qualified Reporting.Doc as D
19−import qualified Reporting.Error.Syntax as Syntax
20−import qualified Reporting.Render.Code as Code
17+import qualified Parse.Primitives as P
2118import qualified Reporting.Report as Report
2219
2320
@@ -25,6 +22,76 @@ import qualified Reporting.Report as Report
2522-- ERROR
2623
2724
25+data Error e
26+ = DecodeProblem (Problem e)
27+ | ParseProblem Word16 Word16 (P.Context Context) ParseExpectation
28+
29+
30+
31+-- DECODE PROBLEMS
32+
33+
34+data Problem e
35+ = Field Utf8.String (Problem e)
36+ | Index Int (Problem e)
37+ | OneOf (Problem e) [Problem e]
38+ | Failure e
39+ | Expecting DecodeExpectation
40+
41+
42+data DecodeExpectation
43+ = TObject
44+ | TArray
45+ | TString
46+ | TBool
47+ | TInt
48+ | TObjectWith Utf8.String
49+ | TArrayPair Int
50+
51+
52+
53+-- PARSE EXPECTATION
54+
55+
56+data ParseExpectation
57+ = ObjectStart
58+ | ObjectMore
59+ | ObjectEnd
60+ | ArrayStart
61+ | ArrayMore
62+ | ArrayEnd
63+ | StringStart
64+ | StringEnd
65+ | IntStart
66+ | NoLeadingZeros
67+ | NoFloats
68+ | Bool
69+ | Null
70+ | Value
71+ | Colon
72+ | EndOfFile
73+
74+
75+
76+data Context
77+ = CIndex Int
78+ | CField Utf8.String
79+
80+
81+
82+-- TO REPORT
83+
84+
85+toReport :: Error e -> Report.Report
86+toReport err =
87+ error "TODO Reporting.Error.Json.toReport" err
88+
89+
90+{-
91+
92+-- ERROR
93+
94+
2895data Error e
2996 = BadJson Syntax.Error
3097 | BadContent (Json.Error e)
@@ -263,3 +330,5 @@ fieldToName field =
263330indexToName :: Int -> String
264331indexToName index =
265332 "[" ++ show index ++ "]"
333+
334+-}