diff options
Diffstat (limited to 'node_modules/loud-rejection')
-rw-r--r-- | node_modules/loud-rejection/api.js | 11 | ||||
-rw-r--r-- | node_modules/loud-rejection/index.js | 36 | ||||
-rw-r--r-- | node_modules/loud-rejection/license | 21 | ||||
-rw-r--r-- | node_modules/loud-rejection/package.json | 59 | ||||
-rw-r--r-- | node_modules/loud-rejection/readme.md | 68 | ||||
-rw-r--r-- | node_modules/loud-rejection/register.js | 2 |
6 files changed, 197 insertions, 0 deletions
diff --git a/node_modules/loud-rejection/api.js b/node_modules/loud-rejection/api.js new file mode 100644 index 0000000..f6cd6a1 --- /dev/null +++ b/node_modules/loud-rejection/api.js @@ -0,0 +1,11 @@ +'use strict'; +var util = require('util'); +var currentlyUnhandled = require('currently-unhandled'); + +// WARNING: This undocumented API is subject to change. + +module.exports = util.deprecate(function (process) { + return { + currentlyUnhandled: currentlyUnhandled(process) + }; +}, 'loudRejection/api is deprecated. Use the currently-unhandled module instead.'); diff --git a/node_modules/loud-rejection/index.js b/node_modules/loud-rejection/index.js new file mode 100644 index 0000000..319b945 --- /dev/null +++ b/node_modules/loud-rejection/index.js @@ -0,0 +1,36 @@ +'use strict'; +var util = require('util'); +var onExit = require('signal-exit'); +var currentlyUnhandled = require('currently-unhandled'); + +var installed = false; + +module.exports = function (log) { + if (installed) { + return; + } + + installed = true; + + log = log || console.error; + + var listUnhandled = currentlyUnhandled(); + + onExit(function () { + var unhandledRejections = listUnhandled(); + + if (unhandledRejections.length > 0) { + unhandledRejections.forEach(function (x) { + var err = x.reason; + + if (!(err instanceof Error)) { + err = new Error('Promise rejected with value: ' + util.inspect(err)); + } + + log(err.stack); + }); + + process.exitCode = 1; + } + }); +}; diff --git a/node_modules/loud-rejection/license b/node_modules/loud-rejection/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/node_modules/loud-rejection/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/loud-rejection/package.json b/node_modules/loud-rejection/package.json new file mode 100644 index 0000000..da5adaf --- /dev/null +++ b/node_modules/loud-rejection/package.json @@ -0,0 +1,59 @@ +{ + "name": "loud-rejection", + "version": "1.6.0", + "description": "Make unhandled promise rejections fail loudly instead of the default silent fail", + "license": "MIT", + "repository": "sindresorhus/loud-rejection", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "xo && nyc ava", + "coveralls": "nyc report --reporter=text-lcov | coveralls" + }, + "files": [ + "index.js", + "register.js", + "api.js" + ], + "keywords": [ + "promise", + "promises", + "unhandled", + "uncaught", + "rejection", + "loud", + "fail", + "catch", + "throw", + "handler", + "exit", + "debug", + "debugging", + "verbose" + ], + "dependencies": { + "currently-unhandled": "^0.4.1", + "signal-exit": "^3.0.0" + }, + "devDependencies": { + "ava": "*", + "bluebird": "^3.0.5", + "coveralls": "^2.11.4", + "delay": "^1.0.0", + "execa": "^0.4.0", + "get-stream": "^2.0.0", + "nyc": "^6.2.1", + "xo": "*" + }, + "nyc": { + "exclude": [ + "fixture.js" + ] + } +} diff --git a/node_modules/loud-rejection/readme.md b/node_modules/loud-rejection/readme.md new file mode 100644 index 0000000..a973261 --- /dev/null +++ b/node_modules/loud-rejection/readme.md @@ -0,0 +1,68 @@ +# loud-rejection [](https://travis-ci.org/sindresorhus/loud-rejection) [](https://coveralls.io/github/sindresorhus/loud-rejection?branch=master) + +> Make unhandled promise rejections fail loudly instead of the default [silent fail](https://gist.github.com/benjamingr/0237932cee84712951a2) + +By default, promises fail silently if you don't attach a `.catch()` handler to them. + +Use this in top-level things like tests, CLI tools, apps, etc, **but not in reusable modules.**<br> +Not needed in the browser as unhandled promises are shown in the console. + + +## Install + +``` +$ npm install --save loud-rejection +``` + + +## Usage + +```js +const loudRejection = require('loud-rejection'); +const promiseFn = require('promise-fn'); + +// Install the unhandledRejection listeners +loudRejection(); + +promiseFn(); +``` + +Without this module it's more verbose and you might even miss some that will fail silently: + +```js +const promiseFn = require('promise-fn'); + +function error(err) { + console.error(err.stack); + process.exit(1); +} + +promiseFn().catch(error); +``` + +### Register script + +Alternatively to the above, you may simply require `loud-rejection/register` and the unhandledRejection listener will be automagically installed for you. + +This is handy for ES2015 imports: + +```js +import 'loud-rejection/register'; +``` + + +## API + +### loudRejection([log]) + +#### log + +Type: `Function`<br> +Default: `console.error` + +Custom logging function to print the rejected promise. Receives the error stack. + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/loud-rejection/register.js b/node_modules/loud-rejection/register.js new file mode 100644 index 0000000..2934812 --- /dev/null +++ b/node_modules/loud-rejection/register.js @@ -0,0 +1,2 @@ +'use strict'; +require('./')(); |