npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

better-promise-error-log

v1.5.2

Published

Better error logs for unhandled errors in promises

Downloads

35

Readme

better-promise-error-log

npm package

NPM version Minzipped size License NPM downloads Dependency Status Dev Dependency Status Open Issues Closed Issues contributions welcome jsDelivr hits

Better error logs for unhandled errors in promises.

Tested with native promises and Bluebird promises.

This module uses the sibling module, jsonify-error, to prepare the error for logging.

Installation

In Browsers

For browsers, simply include one of the dists in your entry point. The dists are available in jsDelivr:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/better-promise-error-log.min.js" integrity="sha384-cyUN0kjnDSNpcYRqS2sNJ6tDyzBAqtW/SwCtK9vDoGYREaHRXrdTsZVK7uwzd2Wl" crossorigin="anonymous"></script>

They are also available as GitHub release assets (since 1.5.1). The following formats are available (with source maps):

  • better-promise-error-log.js
  • better-promise-error-log.min.js (minified)
  • better-promise-error-log.es5.js (ES5 compatible)
  • better-promise-error-log.es5.min.js (ES5 compatible, minified)

In Node

npm install --save better-promise-error-log

Add the following line to the beginning of your entry point:

require("better-promise-error-log");

And then automatically your whole program will have better error logs for unhandled errors in promises.

Example result (in node)

// Uncomment line below to see the difference
// require("better-promise-error-log");
Promise.resolve().then(() => {
    var err = new TypeError("My message");
    err.someField = { something: "whoops" };
    TypeError.prototype.test = "oops!"; // Just to show that it navigates the prototype chain
    throw err;
}).then(() => {
    console.log("This does not execute.");
});

Without require("better-promise-error-log"):

In node, without better-promise-error-log

With require("better-promise-error-log"), you'll get something similar to:

In node, with better-promise-error-log

Note: the whole error formatting is done by the sibling module, jsonify-error.

Example result (in browser)

Promise.resolve().then(() => {
    var err = new TypeError("My message");
    err.someField = { something: "whoops" };
    TypeError.prototype.test = "oops!"; // Just to show that it navigates the prototype chain
    throw err;
}).then(() => {
    console.log("This does not execute.");
});

Without better-promise-error-log:

In browser, without better-promise-error-log

With better-promise-error-log, you'll get something similar to:

In browser, with better-promise-error-log

Note: the whole error formatting is done by the sibling module, jsonify-error.

Contributing

Any contribution is very welcome. Feel free to open an issue about anything: questions, suggestions, feature requests, bugs, improvements, mistakes, whatever. I will be always looking.

Changelog

The changelog is available in CHANGELOG.md.

License

MIT (c) Pedro Augusto de Paula Barbosa