Skip to content

Commit adfbebf

Browse files
committed
improve the error message for trailing commas in JSON
Fixes elm/error-message-catalog#264
1 parent 3f657b6 commit adfbebf

File tree

1 file changed

+10
-2
lines changed
  • compiler/src/Reporting/Error

1 file changed

+10
-2
lines changed

compiler/src/Reporting/Error/Json.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,20 @@ parseErrorToReport path source parseError reason =
7777
)
7878

7979
ObjectField row col ->
80-
toSnippet "UNFINISHED OBJECT" row col
80+
toSnippet "EXTRA COMMA" row col
8181
(
8282
"I was partway through parsing a JSON object when I got stuck here:"
8383
,
8484
D.stack
85-
[ D.reflow $ "I was expecting to see a field name next."
85+
[ D.fillSep
86+
["I","saw","a","comma","right","before","I","got","stuck","here,"
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."
8694
, objectNote
8795
]
8896
)

0 commit comments

Comments
 (0)