Code Monkey home page Code Monkey logo

panic-overlay's Introduction

panic-overlay ๐Ÿ’ฅโœจBuild Status NPM

A lightweight standalone plain JS alternative to react-error-overlay that is not tied to React / Webpack and works with any framework or even without one.

If you miss that thing from create-react-app but do not want to use that framework (e.g. you want to use Parcel as a lightweight alternative) โ€” here you go!

Features

  • Displays runtime errors in browsers
  • Full sourcemap support (shows original code, not transpiled)
  • Clickable locations (opens in VS Code), see the notes here
  • Minimalistic implementation (bare DOM API), easily hackable
  • Uncluttered stacktraces (collapses third party library calls)

How It Looks

Screen Shot 2019-03-11 at 00 11 00

Installation

npm install panic-overlay
import 'panic-overlay' // should be the very first import in your app!

Using Without A Bundler

-TO BE IMPLEMENTED

Disabling Automatic Error Handling

Once imported, panic-overlay shows itself whenever an uncaught error occurs in a browser. You can disable that behavior:

import panic from 'panic-overlay'

panic.configure ({ handleErrors: false })

Showing Manually

panic (error) // where error is either an instance of an Error or a string taken from Error.stack

VS Code Notes

Currently there is a problem with automatically determining the full file paths, so you need to provide it manually, otherwise the error locations won't be clickable:

import panic from 'panic-overlay'

panic.configure ({ projectRoot: '/full/path/to/my/project' })

Custom Click Handler

You can intercept clicks on call stack entries. For the entry format, see this.

panic.configure ({
    stackEntryClicked (entry) {
        alert (`Clicked on ${entry.fileRelative}:${entry.line}:${entry.column}`)
    }
})

TODO

Hacking

The panic-overlay is just a GUI for the stacktracey library that provides all the magic related to callstack parsing, source code extraction and filtering of the clutter. I also maintain that library, so any contributions to its code are welcome as well.

See Also

There is also a way to improve your Node errors (and the overall debug output) legibility by using the Ololog library which is built on the same stack and is maintained by me also. Check it out!

const log = require ('ololog').handleNodeErrors () // intercepts process errors

Screen Shot 2019-04-06 at 00 56 17

Showing locations of log calls:

log.bright.green ('Syncing order books...')

Screen Shot 2019-04-06 at 01 00 10

panic-overlay's People

Contributors

inversia avatar xpl avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.