code-frame-error
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

code-frame-error

just an error with a code frame

Install

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

Use

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 */

Package Sidebar

Install

npm i code-frame-error

Weekly Downloads

9

Version

0.2.0

License

MIT

Unpacked Size

6 kB

Total Files

6

Last publish

Collaborators

  • xiphe