0.1.0 • Published 1 year ago

better-modern-errors v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

better-modern-errors

Why is it better modern errors?

Because modern-errors-commonjs-port was too long

This is blatant copy of Modern Errors. Why?

Because it was in ESM and I needed it in CommonJS. Modern Errors didn't use any of the features of ESM, so I just copied the code out so it could be used in CommonJS. This also required copying all the modules it used that were in ESM too, so all of them are in here as well.

It also includes a handful of the default plugins created by ehmicky for Modern Errors that I thought would be useful for our use case.

See full README for features of Modern Error, all features were included in this copy.

The original library had full test coverage. The tests have been included and migrated to use jest as this was what I was most familiar with and was straightforward to get working with the code being moved to Typescript.

Example

import { BetterError } from 'better-modern-errors'

export const BaseError = BetterError.subclass('BaseError')

export const UnknownError = BaseError.subclass('UnknownError')
export const InputError = BaseError.subclass('InputError')
export const AuthError = BaseError.subclass('AuthError')
export const DatabaseError = BaseError.subclass('DatabaseError')

Install

pnpm install better-modern-errors

Plugins included

import {
  pluginCleanStack,
  pluginHttpResponse,
  pluginProcess,
  pluginSerialize,
  pluginSwitch,
  pluginWinston,
} from 'better-modern-errors';
0.1.0

1 year ago