@hackcapital/errors

0.0.6 • Public • Published

node version status

errors

Overview

Errors provides a modular, extensible and customizable errors.

Environment Variables

  • NODE_DEBUG: Set to 1, to go verbose. More info
  • ERRORS_STACKTRACE_LEVEL: Fine grain control of how many stack frames are collected. More info

Features

  • While testing, you don't need to check for hardcoded values, but by the type of the error. Now, your tests scales :)
    • This is especially important when using dynamic generators/seeders (randomized values) in tests.
  • Named errors increase awareness and add context to whatever you are debugging.
  • Pre-defined message:
    • Change one place, reflect everywhere.
    • i18n!? Ready!
  • Want to enrich/provide more information? You can! These are the current options:
    • extra: Pass a object/JSON and it will be beautified, formatted, and added to the error message.
    • note: Use that to provide more context
    • statusCode: Is the error being used in an HTTP context? Easy one!
    • errorCode: Error code allows you to index all errors, query, and find that very quickly. QA and customers love that!

Usage

Import the package and create a new class that extends the ErrorTemplate class.

Examples

Check the Example page in our Wiki, or the lib/index_test.js file for a full-featured and functional example.

Test

Simple like $ make test

Documentation

Fully documented! Generate with $ make docs

Publishing

This package is private (scoped). After any change, it requires to be published. Follow the steps:

  • Bump package version
  • Create a release
  • Publish the package

Readme

Keywords

Package Sidebar

Install

npm i @hackcapital/errors

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

12.4 kB

Total Files

11

Last publish

Collaborators

  • alexkushner
  • brettcampbell
  • hackcapitaladmin
  • slajax
  • hackcapitalbot
  • jeff_johnson