jsontypedef/json-typedef-codegen

Emit errors as json when `--log-format json` is set.

Opened this issue · 0 comments

In wrapping the cli programmatically, it's easy to process std out with --log-format json. It would be convienent to also be able to parse errors in the same way.

For example, when parsing the invalid jtd:

{ "enum": [1, 2, 3] }

with --log-format json this is output to stderr

Error: Failed to parse input as JSON
      
Caused by:
      invalid type: integer `1`, expected a string at line 1 column 10

Something like this would be what I would expect:

{
    "error": "Failed to parse input as JSON",
    "cause": "invalid type: integer `1`, expected a string at line 1 column 10"
}