@oclif/core 4.11.6 → 4.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/command.js +6 -0
- package/package.json +1 -1
package/lib/command.js
CHANGED
|
@@ -284,6 +284,12 @@ class Command {
|
|
|
284
284
|
return results;
|
|
285
285
|
}
|
|
286
286
|
toErrorJson(err) {
|
|
287
|
+
if (err instanceof Error) {
|
|
288
|
+
// `Error.prototype.message`/`.name` are non-enumerable, so they are dropped
|
|
289
|
+
// by `JSON.stringify` in `logJson`. Surface them explicitly while preserving
|
|
290
|
+
// any enumerable own properties (e.g. a `CLIError`'s `oclif` metadata).
|
|
291
|
+
return { error: { ...err, message: err.message, name: err.name } };
|
|
292
|
+
}
|
|
287
293
|
return { error: err };
|
|
288
294
|
}
|
|
289
295
|
toSuccessJson(result) {
|