https://github.com/carbonicsoda/ts-errno
TypeScript Symbolic Errors for ERRNO
https://github.com/carbonicsoda/ts-errno
constants errno errors typescript
Last synced: 11 months ago
JSON representation
TypeScript Symbolic Errors for ERRNO
- Host: GitHub
- URL: https://github.com/carbonicsoda/ts-errno
- Owner: CarbonicSoda
- License: mit
- Created: 2025-06-08T04:33:42.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-08T07:42:51.000Z (about 1 year ago)
- Last Synced: 2025-06-08T08:25:05.320Z (about 1 year ago)
- Topics: constants, errno, errors, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/ts-errno
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Usage
This package is for ERRNO symbolic constants and error throwing, with full
typing support.
List of ERRNO is based off
[LibUV/Errors](https://docs.libuv.org/en/stable/errors.html) (adopted by
Node.js). Corresponding number codes are not included, as they are not
cross-platform consistent.
Install this package in your project:
```bash
# via npm
npm add ts-errno
# or pnpm
pnpm add ts-errno
# or yarn
yarn add ts-errno
```
Now errors could be thrown easily:
```ts
// 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.`;
}
```