@robotmayo/stderror
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

StdError

A small extension of the error adding code and context.

npm i @robotmayo/stderror

Usage

Use it similar to how you would use a normal error.

import StdError from "@robotmayo/stderror";
// Or with commonjs
const StdError = require("@robotmayo/stderror").default;
function thisWillThrow() {
  throw new StdError("Something went wrong.", "AUTH_ERROR");
}

Api

new StdError(message, code, [context])

Parameter Required Type Description
message True string The error message
code True string The error code. Recommended to be all caps, underscores instead of spaces
context False Object Object containing potentially useful meta information with the error

Readme

Keywords

Package Sidebar

Install

npm i @robotmayo/stderror

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

2.6 kB

Total Files

5

Last publish

Collaborators

  • robotmayo