# code-frame-error

> just an error with a code frame

Latest version **0.2.0** (published 2022-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install code-frame-error
pnpm add code-frame-error
yarn add code-frame-error
bun add code-frame-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.2.0 |
| Published | 2022-08-08 |
| First published | 2022-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hannes Diercks |
| Maintainers | xiphe |
| Keywords | error, code-frame, syntax, error, file, error |

## Links

- npm: https://www.npmjs.com/package/code-frame-error
- Repository: https://github.com/Xiphe/code-frame-error
- Homepage: https://github.com/Xiphe/code-frame-error#readme
- Issues: https://github.com/Xiphe/code-frame-error/issues
- npm.io page: https://npm.io/package/code-frame-error

## Dependencies (2)

- [@babel/code-frame](https://npm.io/package/@babel/code-frame.md) ^7
- [@types/babel__code-frame](https://npm.io/package/@types/babel__code-frame.md) ^7

## 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.2.0 (latest) — 2022-08-08
- 0.1.2 — 2022-08-08
- 0.1.1 — 2022-08-08
- 0.1.0 — 2022-08-08

## README

# code-frame-error

just an error with a [code frame](https://babeljs.io/docs/en/babel-code-frame)

## Install

```bash
npm install code-frame-error
# yarn add code-frame-error
```

## Use

```ts
import CodeFrameError, { File } from 'code-frame-error';
import type { BabelCodeFrameOptions } from '@babel/code-frame';

const file: File = {
  name: 'text.txt',
  rawLines: 'lorem ipsum sit amet',
  location: {
    start: { line: 1, column: 13 },
    end: { line: 1, column: 16 },
  },
};
const err = new CodeFrameError('Unexpected sit, expected dolor', file);

const options: BabelCodeFrameOptions = {};
console.log(err.toString(options));
/*

CodeFrameError: Unexpected sit, expected dolor

text.txt:1:13
> 1 | lorem ipsum sit amet
    |             ^^^

*/

console.log(err instanceof Error);
/* true */
```

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