Skip to content

Commit

Permalink
fix(workspace): error message to be readable in error toast
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshita-mindfire committed Feb 15, 2022
1 parent d913a7f commit 25c74e8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/plugin-core/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { CONFIG, DENDRON_CHANNEL_NAME } from "./constants";
import * as vscode from "vscode";
import { FileItem } from "./external/fileutils/FileItem";
import _ from "lodash";

export type TraceLevel = "debug" | "info" | "warn" | "error" | "fatal";
const levels = ["debug", "info", "warn", "error", "fatal"];
Expand Down Expand Up @@ -160,11 +161,18 @@ export class Logger {
_opts?: { show?: boolean }
) => {
if (Logger.cmpLevel(lvl)) {
const payloadWithErrorAsPlainObject = {
...payload,
error: payload.error ? error2PlainObject(payload.error) : payload.error,
};
const stringMsg = customStringify(payloadWithErrorAsPlainObject);
let stringMsg: string;
if (_.isString(payload)) {
stringMsg = payload;
} else {
const payloadWithErrorAsPlainObject = {
...payload,
error: payload.error
? error2PlainObject(payload.error)
: payload.error,
};
stringMsg = customStringify(payloadWithErrorAsPlainObject);
}
Logger.logger?.[lvl](payload);
Logger.output?.appendLine(lvl + ": " + stringMsg);
// FIXME: disable for now
Expand Down

0 comments on commit 25c74e8

Please sign in to comment.