# catch-err-msg

> Helper function to extract error message for TypeScript 4.4+ `catch` clause

Latest version **1.0.0** (published 2021-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install catch-err-msg
pnpm add catch-err-msg
yarn add catch-err-msg
bun add catch-err-msg
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-10-06 |
| First published | 2021-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.0.0 |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mgenware |
| Maintainers | mgenware |

## Links

- npm: https://www.npmjs.com/package/catch-err-msg
- Repository: https://github.com/mgenware/catch-err-msg
- Issues: https://github.com/mgenware/catch-err-msg/issues
- npm.io page: https://npm.io/package/catch-err-msg

## Recent versions

- 1.0.0 (latest) — 2021-10-06

## README

# catch-err-msg

[![Build Status](https://github.com/mgenware/catch-err-msg/workflows/Build/badge.svg)](https://github.com/mgenware/catch-err-msg/actions)
[![MEAN Module](https://img.shields.io/badge/MEAN%20Module-TypeScript-blue.svg?style=flat-square)](https://github.com/mgenware/catch-err-msg)
[![npm version](https://img.shields.io/npm/v/catch-err-msg.svg?style=flat-square)](https://npmjs.com/package/catch-err-msg)
[![Node.js Version](http://img.shields.io/node/v/catch-err-msg.svg?style=flat-square)](https://nodejs.org/en/)

Helper function to extract error message for TypeScript 4.4+ `catch` clause.

```ts
import errMsg from 'catch-err-msg';

try {
  // ...
} catch (err) {
  // err: unknown in TypeScript 4.4+
  const message = errMsg(err);
  console.error(message);
}
```

## Source

```ts
export default function errMsg(err: any): string {
  return err?.message ? `${err.message}` : `${err}`;
}
```

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