Skip to content

Commit

Permalink
Merge pull request #125 from ejose19/ej/excludeNameFromErrorDetails
Browse files Browse the repository at this point in the history
Exclude error name from "IErrorObject"
  • Loading branch information
terehov authored Nov 29, 2021
2 parents 1e4983a + 29b227b commit 1060bb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/LoggerWithoutCallSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,15 @@ export class LoggerWithoutCallSite {
relevantCallSites.length = stackLimit;
}

const {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
name: _name,
...errorWithoutName
} = error;

const errorObject: IErrorObject = {
nativeError: error,
details: { ...error },
details: { ...errorWithoutName },
name: error.name ?? "Error",
isError: true,
message: error.message,
Expand Down
2 changes: 2 additions & 0 deletions tests/error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ describe("Logger: Error with details", () => {
loggerPretty.warn(error);
expect(doesLogContain(stdErr, "TestError")).toBeTruthy();
expect(doesLogContain(stdErr, ".test.ts")).toBeTruthy();
expect(doesLogContain(stdErr, "details:")).toBeFalsy();
});

test("JSON: Error with details (stdErr)", (): void => {
const error = new TestError("TestError");
loggerJson.warn(error);
expect(doesLogContain(stdErr, "TestError")).toBeTruthy();
expect(doesLogContain(stdErr, ".test.ts")).toBeTruthy();
expect(doesLogContain(stdErr, '"details":{}')).toBeTruthy();
});

test("JSON: Check if call site wrapping is working (Bugfix: #29)", (): void => {
Expand Down

0 comments on commit 1060bb2

Please sign in to comment.