Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude error name from "IErrorObject" #125

Merged

Conversation

ejose19
Copy link
Contributor

@ejose19 ejose19 commented Nov 27, 2021

It's redundant to include error name in details (like we're not including other native Error properties there), so this PR excludes that property so classes extending Error have a cleaner output.

Repro code:

import { Logger } from "tslog";
const logger = new Logger();

class CustomError extends Error {
  constructor(message?: string) {
    super(message);
    this.name = "CustomError";
  }
}

logger.error(new CustomError("foo"));

Current output:

CustomError  foo
details:
{
  name: 'CustomError'
}
error stack:
...

Output after this PR:

CustomError  foo
error stack:
...

@terehov terehov changed the base branch from master to development November 29, 2021 10:16
@terehov terehov merged commit 1060bb2 into fullstack-build:development Nov 29, 2021
@terehov
Copy link
Contributor

terehov commented Nov 29, 2021

Thanks, looks quite handy. I just merged it

terehov added a commit that referenced this pull request Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants