You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: With --json, print errors as JSON too #1711
When --json is given, the errors that today go to stderr as plain text would also come as one JSON document, with the same exit codes. These are the errors before a job starts: wrong arguments, a missing input, no files to convert, an unknown format, preset or engine, and watch failing to start.
{ "error": "unknown format 'jgp'. Run 'filee formats' for the list.", "errorKey": "cli.unknown_format" }
Messages stay in English (#552), and output without --json doesn't change.
Why / when would you use it?
engines install --json already returns its failures in its JSON document (#935), and convert --json gives each failed file an errorKey. Anything that fails before that is plain text on stderr. So a program has to read JSON for some failures and parse English text for others, which is what Molt does today. With an errorKey, a front end could show its own message (in its own language) without matching text.
Ideas for how it could work
A few things I'd like your call on:
Where the document goes: stdout, as engines does, or stderr?
The keys: a small fixed set, for example cli.usage, cli.not_found, cli.no_files, cli.unknown_format, cli.unknown_preset, cli.unknown_engine, cli.watch_failed.
watch --json: an {"event":"error", …} line instead, so its stdout stays a stream of events?
I'd like to work on this, after the parser fix (#1709).
Activity