Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

better-promise-error-log

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-promise-error-log

Better error logs for unhandled errors in promises

  • 1.4.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Weekly downloads
 
Created
Source

better-promise-error-log

npm package

NPM version 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, such as dist/better-promise-error-log.js. The dists are available in jsDelivr:

<script src="https://cdn.jsdelivr.net/npm/better-promise-error-log@1.4.3/dist/better-promise-error-log.js" integrity="sha384-FSQKT2TZIXJM7bcJcAAoxX07ORDy1I8RQ+Jz4gzsiCOspkZG8+61HQ1ymMgami//" crossorigin="anonymous"></script>

The following dists are available (with source maps):

  • dist/better-promise-error-log.js
  • dist/better-promise-error-log.min.js
  • dist/better-promise-error-log.es5.js
  • dist/better-promise-error-log.es5.min.js

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

Keywords

FAQs

Package last updated on 31 Oct 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc