@biorate/errors
TypeScript icon, indicating that this package has built-in type declarations

1.28.0 • Public • Published

Errors factory

This module provides a base class for creating error classes with error code (class name), message template, meta data support out of the box.

Example:

import { BaseError } from '@biorate/errors';

export class MyAwesomeError extends BaseError {
  constructor(args?: unknown[], meta?: unknown) {
    super(`Oops... Some error happen, at [%s], in [%s]`, args, meta);
  }
}

const e = new MyAwesomeError([new Date(), 'core'], { hello: 'world!' });

console.log(e.meta); // { hello: 'world!' }
console.log(e.code); // MyAwesomeError

throw e;
          ^
MyAwesomeError: Oops... Some error happen, at [2021-05-13T09:19:22.511Z], in [core]
    at Object.<anonymous> (..core/packages/@biorate/errors/index.ts:28:11)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Readme

Keywords

none

Package Sidebar

Install

npm i @biorate/errors

Weekly Downloads

67

Version

1.28.0

License

MIT

Unpacked Size

124 kB

Total Files

35

Last publish

Collaborators

  • llevkin