intlc icon indicating copy to clipboard operation
intlc copied to clipboard

Print more error context

Open samhh opened this issue 3 years ago • 1 comments

Off the back of #114/#115, it'd be great to have more lines/context around errors. Example:

./x-all.json:6:21:
  |
6 |     "message": "{x, bad}"
  |                     ^^^^^^
unexpected "bad}"<newline>  },<newline>  "
expecting "boolean", "date", "number", "plural", "select", "selectordinal", "time", or white space

I can see the line number and the problem itself, which is good, however ideally it'd also show the line above with the translation name. In an ideal world we would always show everything in the object:

./x-all.json:6:21:
  |
5 |   "f": {
6 |     "message": "{x, bad}"
  |                     ^^^^^^
7 |   }
  |
unexpected "bad}"<newline>  },<newline>  "
expecting "boolean", "date", "number", "plural", "select", "selectordinal", "time", or white space

samhh avatar May 03 '22 14:05 samhh

This is relevant to linting output as well as of #179.

It's unclear how well this would scale. The object may be large and the message mayn't be at the top.

samhh avatar Nov 01 '22 12:11 samhh