Socket
Socket
Sign inDemoInstall

babel-errors

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-errors

Nicer error messages for Babel


Version published
Weekly downloads
1.4K
increased by1.82%
Maintainers
1
Install size
4.51 kB
Created
Weekly downloads
 

Readme

Source

babel-errors

Nicer error messages for Babel

import createBabelFile from 'babel-file';
import {BabelError, prettyError, buildCodeFrameError} from 'babel-errors';

const file = createBabelFile(...);

let path = file.path;
let {line, column} = path.loc.start;

throw prettyError(createErrorWithLoc('Error at this position', line, column));
throw buildCodeFrameError(path, 'Error with this Path');

createErrorWithLoc(message, line, column)

This lets you add location information to your errors.

wrapErrorWithCodeFrame(err)

You can use this when capturing errors thrown by Babel or constructed using createErrorWithLoc to add a code frame when possible.

buildCodeFrameError(path, message)

You can use this to build a code frame error around a path with a specified message.

Use this instead of path.buildCodeFrameError when you aren't running inside a Babel plugin.

toErrorStack(error)

Creates string with error name, message, stack/code frame.

FAQs

Last updated on 29 May 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc