Skip to content

Check err when is used when logging error #9

@witoszekdev

Description

@witoszekdev

What I'm trying to achieve

We use err from neverthrow sometimes in our app, this can be confused with err in error handler.

import {err} from "neverthrow";

// ...

return err(new Error("Test"));

// ...

logger.info("Error!", {err}); // -> err is not defined, so we will use neverthrow function

vs

// ...

try {
  throw new Error("test");
} catch (err) {
  logger.info("Oh no!", {err}); // -> this works fine
}

Describe a proposed solution

  • Detect if function is passed to logger, if so raise warning
  • Detect if error was passed e.g. without obfuscating potential PII (e.g. stacktrace) (maybe we shouldn't allow Error instances at all? keep in mind we also use modern-error)

Other solutions I've tried and won't work

Remembering about it every time :)

Screenshots or mockups

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions