1.5.0 • Published 2 years ago

@thundercraft5/node-errors v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

node-errors is a library that streamlines the creation and management of message-coded errors. Has 0 dependencies!

Usage

Use makeErrors(messages, errorMap, includeNativeCodes?) to create coded error classes.

import makeErrors from "@thundercraft5/node-errors";

const { MyError } = makeErrors({
    "TEST_CODE": "This is a test message!",
}, {
    MyError: class MyError extends Error {},
}, /* set this parameter to `true` to include built-in codes in the available messages */ false);

throw new MyError("TEST_CODE"); // MyError [TEST_CODE]: This is a test message!

Alternatively, use the built-in error classes instead.

import { Error } from "@thundercraft5/node-errors";

throw new Error("METHOD_NOT_IMPLEMENTED", Error, "test"); // Error [METHOD_NOT_IMPLEMENTED]: Method Error#test() is not implemented.

NOTES:

  • Targeted/Built for ESNext.
  • ESM-Only.
  • May be run in the browser with a bundler.
1.5.0

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.2.1

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago