1.0.0 • Published 6 years ago

@robotmayo/stderror v1.0.0

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

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])

ParameterRequiredTypeDescription
messageTruestringThe error message
codeTruestringThe error code. Recommended to be all caps, underscores instead of spaces
contextFalseObjectObject containing potentially useful meta information with the error