# catched-error-message

> helper method to get message from catched error

Latest version **0.0.1** (published 2023-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install catched-error-message
pnpm add catched-error-message
yarn add catched-error-message
bun add catched-error-message
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-12-15 |
| First published | 2023-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tommy Bernaciak |
| Maintainers | tommybernaciak |
| Keywords | typescript, error, message, catch |

## Links

- npm: https://www.npmjs.com/package/catched-error-message
- Repository: https://github.com/tommybernaciak/catched-error-message
- Homepage: https://github.com/tommybernaciak/catched-error-message#readme
- Issues: https://github.com/tommybernaciak/catched-error-message/issues
- npm.io page: https://npm.io/package/catched-error-message

## 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-12-15

## README

# catched-error-message

## Why

Because you would like to run code as below:

```typescript
try {
  throw new Error("some crazy stuff");
} catch (error) {
  doSomethingWithErrorMessage({ message: error.message });
}
```

But TypeScript defaults error type to `unknown`. And this is actually correct, since you can throw literally anything:

```typescript
throw 'messgae'
throw 123
throw {but: 'why?'}
throw null
throw undefined
...
```

## Solution

This little package is a solution for thi problem. Just use it as below:

```typescript
try {
  throw new Error("some crazy stuff");
} catch (error) {
  doSomethingWithErrorMessage({ message: getErrorMessage(error) });
}
```

And voilà, you get your message, no TS error.

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