Détail du package

modern-errors-clean

ehmicky4.9kMIT6.0.1

modern-errors plugin to clean stack traces

browser, clean, code-quality, cwd

readme

<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ehmicky/design/main/modern-errors/modern-errors_dark.svg"/> modern-errors logo </picture>

Node TypeScript Codecov Mastodon Medium

modern-errors plugin to clean stack traces.

Features

  • Shorten file paths, making them relative to the current directory
  • Replace the home directory with ~
  • Remove unhelpful internal Node.js entries

Example

Adding the plugin to modern-errors.

import ModernError from 'modern-errors'

import modernErrorsClean from 'modern-errors-clean'

export const BaseError = ModernError.subclass('BaseError', {
  plugins: [modernErrorsClean],
})
// ...

error.stack (before):

Error: message
    at exampleFunction (/home/ehmicky/repo/dev/example.js:7:2)
    at main (/home/ehmicky/repo/dev/main.js:2:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)

error.stack (after):

Error: message
    at exampleFunction (dev/example.js:7:2)
    at main (dev/main.js:2:15)

Install

npm install modern-errors-clean

This package requires Node.js >=18.18.0.

This is an ES module. It must be loaded using an import or import() statement, not require(). If TypeScript is used, it must be configured to output ES modules, not CommonJS.

API

modernErrorsClean

Type: Plugin

Plugin object to pass to the plugins option of ErrorClass.subclass().

Related projects

Support

For any question, don't hesitate to submit an issue on GitHub.

Everyone is welcome regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.

Contributing

This project was made with ❤️. The simplest way to give back is by starring and sharing it online.

If the documentation is unclear or has a typo, please click on the page's Edit button (pencil icon) and suggest a correction.

If you would like to help us fix a bug or add a new feature, please check our guidelines. Pull requests are welcome!

changelog

6.0.1

Documentation

  • Improve documentation in README.md

6.0.0

Breaking changes

  • Minimal supported Node.js version is now 18.18.0

5.0.0

Breaking changes

  • Minimal supported modern-errors version is now 6.0.0

4.0.0

Breaking changes

  • Minimal supported Node.js version is now 16.17.0

3.1.0

Features

  • Upgrade to the latest version of modern-errors

3.0.0

Breaking changes

2.1.0

Features

  • Improve tree-shaking support

2.0.0

Breaking changes

  • Renamed the package from modern-errors-stack to modern-errors-clean

1.2.0

Features

1.1.0

Documentation

Improve README.

1.0.0

Initial release.