# @metaplex-foundation/cusper

> Resolves Custom Program Errors from Solana program logs or error codes.

Latest version **0.0.2** (published 2021-12-28) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @metaplex-foundation/cusper
pnpm add @metaplex-foundation/cusper
yarn add @metaplex-foundation/cusper
bun add @metaplex-foundation/cusper
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-12-28 |
| First published | 2021-12-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 54.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Thorsten Lorenz |
| Maintainers | aaron, thlorenz, austbotm |
| Keywords | solana, blockchain, errors, custom program error, utilities |

## Links

- npm: https://www.npmjs.com/package/@metaplex-foundation/cusper
- Repository: https://github.com/metaplex-foundation/cusper
- Homepage: https://github.com/metaplex-foundation/cusper#readme
- Issues: https://github.com/metaplex-foundation/cusper/issues
- npm.io page: https://npm.io/package/@metaplex-foundation/cusper

## 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.2 (latest) — 2021-12-28
- 0.0.1 — 2021-12-28

## README

# Cusper [![Build Lint and Test Cusper](https://github.com/metaplex-foundation/cusper/actions/workflows/build-lint-test.yml/badge.svg)](https://github.com/metaplex-foundation/cusper/actions/workflows/build-lint-test.yml)

Resolves Custom Program Errors from Solana program logs or error codes.

## Example

```ts
import { initCusper } from '@metaplex-foundation/cusper'

const cusper = initCusper(/* optionally provide custom error resolver here */)

const logs = [
  'Program CwrqeMj2U8tFr1Rhkgwc84tpAsqbt9pTt2a4taoTADPr invoke [1]',
  'Program log: Custom program error: 0x07D0',
]
function showError() {
  try {
    const error = { ...new Error('Test error'), logs }
    cusper.throwError(error)
  } catch (err) {
    console.error(err)
  }
}

showError()
```

```
AnchorError#ConstraintMut: A mut constraint was violated
    at showError (/cusper/test/test/ex.ts:13:12)
    [ .. ]
```

## API

Please find the [API docs here](https://metaplex-foundation.github.io/cusper/docs/)

## LICENSE

Apache-2.0

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