Skip to content

[Feature]: With --json, print errors as JSON too #1711

Open

Description

@yavuzmeteafsar

What would you like Filee to do?

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions