# browser-exception-collector

> An exception collector for browser

Latest version **0.1.0** (published 2021-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install browser-exception-collector
pnpm add browser-exception-collector
yarn add browser-exception-collector
bun add browser-exception-collector
```

## 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.1.0 |
| Published | 2021-05-23 |
| First published | 2021-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 67 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Qingrong Ke |
| Maintainers | dearke |
| Keywords | collector, error, exception, exception-collector |

## Links

- npm: https://www.npmjs.com/package/browser-exception-collector
- Repository: https://github.com/keqingrong/browser-exception-collector
- Homepage: https://github.com/keqingrong/browser-exception-collector#readme
- Issues: https://github.com/keqingrong/browser-exception-collector/issues
- npm.io page: https://npm.io/package/browser-exception-collector

## Dependencies (1)

- [mitt](https://npm.io/package/mitt.md) ^2.1.0

## 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.1.0 (latest) — 2021-05-23

## README

# browser-exception-collector (WIP)

[![npm version](https://img.shields.io/npm/v/browser-exception-collector.svg)](https://www.npmjs.com/package/browser-exception-collector)

An exception collector for browser

## Installation

```bash
# npm
npm install browser-exception-collector

# yarn
yarn add browser-exception-collector
```

## Usage

```ts
import { ExceptionCollector } from 'browser-exception-collector';

const collector = new ExceptionCollector();

collector.onError(error => {
  console.error('onError', error);
  console.log('onError', JSON.parse(error.toJSON()));
});

collector.onUnhandledRejection(error => {
  console.error('onUnhandledRejection', error);
  console.log('onUnhandledRejection', JSON.parse(error.toJSON()));
});
```

## APIs

- ExceptionCollector
  - `new ExceptionCollector(options)`
    - `options.debug`
  - `ExceptionCollector.prototype.dispose()`
  - `ExceptionCollector.prototype.on(type, handler)`
  - `ExceptionCollector.prototype.onError(handler)`
  - `ExceptionCollector.prototype.onUnhandledRejection(handler)`
  - `ExceptionCollector.prototype.onRejectionHandled(handler)`
- CustomError
  - `new CustomError(message, errorInit)`
  - `CustomError.prototype.toString()`
  - `CustomError.prototype.toJSON()`

## License

MIT © Qingrong Ke

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