Class: JsonOutputError
Error raised by the global options plugin for the JSON output, when a command is given --json.
err:json:not-supported: the command does not spreadjsonArgs. It is raised before the command runs, and thrown in anAggregateError, as the argument errors are.err:json:invalid-result: the command finished, but did not return an object to output as JSONerr:json:unserializable-result: the command finished, but its result cannot be converted to JSON, such as an object with aBigInt
The plugin prints it as one line of JSON to stderr, and cli() resolves with undefined. For err:json:not-supported, with renderValidationErrors: null or usageSilent, nothing is printed and cli() rejects with the AggregateError, as it does for the argument errors.
Use isJsonOutputError to tell it, since each package bundles its own copy of this class.
Extends
Error
Signature
ts
export class JsonOutputError extends ErrorConstructors
Constructor
ts
new JsonOutputError(message: string, options: JsonOutputErrorOptions): JsonOutputError;Create an error of the JSON output.
Parameters
| Name | Type | Description |
|---|---|---|
message | string | Fallback error message |
options | JsonOutputErrorOptions | The code of the error, and the values of its message |
Returns
Properties
| Name | Type | Description |
|---|---|---|
code (readonly) | JsonOutputErrorCode | The code of the error, which is also the resource key of its message. |
values (readonly) | Record<string, unknown> | Values used when localizing the message. |
