1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Simplify Error.cause logging (#6669)

- Errors from "request" package (and thus the "@kubernetes/client-node"
  package too) contain a "response" field which is very large and has
  redundent information on it

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-12-13 03:39:07 -08:00 committed by GitHub
parent 012944d562
commit 4d58219376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import { LEVEL, MESSAGE, SPLAT } from "triple-beam";
import chalk from "chalk";
import type { InspectOptions } from "util";
import { inspect } from "util";
import { omit } from "lodash";
// The following license was copied from https://github.com/duccio/winston-console-format/blob/master/LICENSE
// This was modified to support formatting causes
@ -112,8 +113,8 @@ export class ConsoleFormat {
const messages: string[] = [];
if (source instanceof Error && source.cause) {
messages.push(`Cause: ${source.cause}`);
messages.push(...this.getLines(source.cause).map(l => ` ${l}`));
messages.push("Cause:");
messages.push(...this.getLines(omit(source.cause, "response")).map(l => ` ${l}`));
messages.push(...this._cause(source.cause));
}