on master help sign in
improve the error message for trailing commas in JSON
adfbebfEvan Czaplicki
compiler/src/Reporting/Error/Json.hs+10−2
@@ -77,12 +77,20 @@ parseErrorToReport path source parseError reason =
77 )
77 )
78
78
79 ObjectField row col ->
79 ObjectField row col ->
80− toSnippet "UNFINISHED OBJECT" row col
80+ toSnippet "EXTRA COMMA" row col
81 (
81 (
82 "I was partway through parsing a JSON object when I got stuck here:"
82 "I was partway through parsing a JSON object when I got stuck here:"
83 ,
83 ,
84 D.stack
84 D.stack
85+ [ D.fillSep
86+ ["I","saw","a","comma","right","before","I","got","stuck","here,"
85− [ D.reflow $ "I was expecting to see a field name next."
87+ ,"so","I","was","expecting","to","see","a","field","name","like"
88+ ,D.dullyellow "\"type\"","or",D.dullyellow "\"dependencies\"","next."
89+ ]
90+ , D.reflow $
91+ "This error is commonly caused by trailing commas in JSON objects. Those are\
92+ \ actually disallowed by <https://json.org> so check the previous line for a\
93+ \ trailing commas that may need to be deleted."
86 , objectNote
94 , objectNote
87 ]
95 ]
88 )
96 )