# presentable-error

> Make presentable errors

Latest version **0.0.1** (published 2023-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install presentable-error
pnpm add presentable-error
yarn add presentable-error
bun add presentable-error
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-08-25 |
| First published | 2023-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 62 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | error, presentable |

## Links

- npm: https://www.npmjs.com/package/presentable-error
- Repository: https://github.com/sindresorhus/presentable-error
- Homepage: https://github.com/sindresorhus/presentable-error#readme
- Issues: https://github.com/sindresorhus/presentable-error/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/presentable-error

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2023-08-25

## README

# presentable-error

> Make presentable errors

**Work in progress. Request for feedback.**

The idea is to create a convention for errors that are meant to be presented to the user without a stack trace. Same as any object with a `.then` property can be awaited (duck-typing), I would like to create a convention where every error with a `.isPresentable` property should be presented to the user in a nicer way. This is especially useful for command-line tools. For example, if a command-line tool uses packages that follow the presentable error convention, the command-line tool could simply check for `error.isPresentable` and then log it nicely instead of throwing such errors.

This package comes with types for creating presentable errors and checking for them, but if you follow the convention, you don't even need to use this package directly. This can be useful if you want to use your own error subclasses. Then you can simply add the `.isPresentable` property. Ensure it's non-writable and non-configurable.

## Install

```sh
npm install presentable-error
```

## Usage

See [`index.d.ts`](index.d.ts) for now.

#### Example in CLI

```js
import meow from 'meow';

try {
	throwableFunction();
} catch (error) {
	if (error.isPresentable) {
		console.error(error.message);
		process.exit(1);
	}

	throw error;
}
```

---
_Source: https://npm.io/package/presentable-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
