ts-errno
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Usage

This package is for ERRNO symbolic constants and error throwing, with full typing support.

List of ERRNO is based off LibUV/Errors (adopted by Node.js). Corresponding number codes are not included, as they are not cross-platform consistent.

Install this package in your project:

# via npm
npm add ts-errno

# or pnpm
pnpm add ts-errno

# or yarn
yarn add ts-errno

Now errors could be thrown easily:

// demo.ts
import { err } from "ts-errno";

// throw with additional message
if (!exist(file)) {
    throw err("ENOENT")`${file} not found.`;
}

// throw with additional details
try {
    open(file);
} catch (e) {
    throw err("ENOENT", e)`${file} not found.`;
}

Package Sidebar

Install

npm i ts-errno

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

13.9 kB

Total Files

6

Last publish

Collaborators

  • carbonsoda