0.0.4 • Published 6 years ago

node-error-codes v0.0.4

Weekly downloads
346
License
ISC
Repository
github
Last release
6 years ago

Error codes for Node.js > 8.0

Why

Recently node.js added Error#code https://medium.com/the-node-js-collection/node-js-errors-changes-you-need-to-know-about-dc8c82417f65

But currently it doesn't export the "strings" via internal module.\ So I've created this static ES6 Modules that exports constants.\ So you can figure out typos during bundle time.

Usage:

The modules exports constants

ES6+:

import { ERR_ASSERTION } from "node-error-codes";

try {
  assert(false, "False");
} catch (err) {
  if (err.code === ERR_ASSERTION) {
    console.log("An assertion error was thrown");
  }
}

CommonJS:

const errorCodes = require("node-error-codes");

try {
  assert(false, "False");
} catch (err) {
  if (err.code === errorCodes.ERR_ASSERTION) {
    console.log("An assertion error was thrown");
  }
}

Building

Run gen.js node which fetches the latest error codes from node.js /lib/internal/errors.js.
Parses with babylon, and creates error_codes.mjs
System Errors with libUV hasnt been implemented yet!

TODO:

Configure tests/linter.
Implement libuv errors.

Liscence: ISC

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago