{"name":"yerror","version":"4.0.1","description":"It helps to know why you got an error.","main":"src/index.js","types":"src/index.d.ts","browser":"dist/index.js","scripts":{"build":"rm -rf dist && babel src -d dist && npm run test:build","cli":"env NPM_RUN_CLI=1","cover":"istanbul cover --report html _mocha -- src/*.mocha.js -R spec -t 5000","coveralls":"istanbul cover _mocha --report lcovonly -- src/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage","lint":"eslint src/*.js","preversion":"npm run lint && npm build && npm test","test":"mocha src/*.mocha.js && karma start karma.conf.js","test:build":"mocha dist/*.mocha.js"},"engines":{"node":">=6.0.0"},"repository":{"type":"git","url":"git://github.com/SimpliField/yerror.git"},"keywords":["error","why","better"],"author":{"name":"Nicolas Froidure","url":"Simplifield"},"license":"MIT","bugs":{"url":"https://github.com/SimpliField/yerror/issues"},"devDependencies":{"babel-cli":"^6.24.1","babel-plugin-transform-builtin-extend":"^1.1.2","babel-preset-es2015":"^6.24.1","browserify":"^14.4.0","coveralls":"~2.11.2","eslint":"^3.4.0","eslint-config-simplifield":"^4.1.1","istanbul":"^0.4.2","karma":"^1.7.0","karma-browserify":"^5.1.1","karma-chrome-launcher":"^2.2.0","karma-firefox-launcher":"^1.0.1","karma-mocha":"^1.3.0","karma-sauce-launcher":"^1.1.0","mocha":"^3.0.2","mocha-lcov-reporter":"^1.0.0"},"dependencies":{},"gitHead":"1b223c70a140e004c7a2871c22c1dce6446e8651","homepage":"https://github.com/SimpliField/yerror#readme","_id":"yerror@4.0.1","_npmVersion":"6.5.0","_nodeVersion":"8.12.0","_npmUser":{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},"dist":{"integrity":"sha512-Fv708GtSK+5sA8FEvRvuCEsIuE9jZ5ilrPpl8cRNX4Yhd4K8dGwi+9ky7O2Ghb4KRZvSifFU9mD4/j8iqeCpmg==","shasum":"099b80ace40cc8480db6ac6d5995338ff4422ed4","tarball":"http://registry-npm.ywwl.com/yerror/download/yerror-4.0.1.tgz","fileCount":15,"unpackedSize":224097,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcVUy0CRA9TVsSAnZWagAARFgP/jnlDlEm0DqYiZr/3eJM\nRowdyPzu8P9VUjct2Myu8k4hbgN0Izcadvf6Nja5BqpHSF4RmTpkVPZMRqrb\nomXTwRmpejaE42t4i5HldYgzZHsefRBzgbCg0VullyrAMy/zQzgpqW8aW9Ue\nJ37rnDsmzKqZwn63u1wjNI8zBV5wrSBT3TxSSNmjKKo8HcqoGe3HXnAIggDj\na6eTgKU/Xq8l1KwxQjj1DtXpCqvlgRWjAuYlTjTZNmhH+zRizcPhwC7DZRdy\nubvCytQhh6wGg6zWX97BJdH/ri72OyRXmJlfUD2rh7zFGHXPU3T9NVCw49qp\n/E8Tjfgnfq4XCKYPTGPIMcLmMivxVtedO3y0Ksga/EL5kW3Bf97PlnawDvtB\nSV/Gyn6iwgOgmSMNz7h5kBC1L+tc/QNrE6WDrqtUR1Z0UQWakat18sJBprqv\n7BdsqI6uy9t716lqWUBc/CDCxMOORQFJPdlJ6+SM95tOxBxzqvMcHyI9f34d\nDnKGSNHP/MJTBCMLciMfBHeELWCnEYOkzuUYyFyoA6zlu34YET73w7EY+y6V\nJXxORStlkX2pEHNHuHL7PV/fazrcQUGvGQC2AK68w+w/H1cDEg3L2FW/KvsM\n5tDCmi+pldvaIbLUVM2NFubH6b41pdtZE7h6+/G7+CYg2EIMf6NQn0Bgjcm/\nn99o\r\n=mtzI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIASVhFNvlVUQenvDsfbSFUUonjygCAn6WkrCQHyzgipMAiAI4cNI+HXofSx0RMK2AetvQtv4eSeYXEszNskbqk430Q=="}],"size":54850,"noattachment":false,"key":"/yerror/-/yerror-4.0.1.tgz"},"maintainers":[{"name":"arnaudspanneut","email":"arnaudspanneut@gmail.com"},{"name":"gplancke","email":"georges.plancke@gmail.com"},{"name":"nfroidure","email":"nfroidure@elitwork.com"},{"name":"sebastienelet","email":"sebastien@elet.fr"},{"name":"xavhan","email":"xavhan@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/yerror_4.0.1_1549094067525_0.0034875115737804663"},"_hasShrinkwrap":false,"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# yerror\n> It helps to know why you got an error.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/yerror/blob/main/LICENSE)\n[![Coverage Status](https://coveralls.io/repos/github/git://github.com/nfroidure/yerror.git/badge.svg?branch=main)](https://coveralls.io/github/git://github.com/nfroidure/yerror.git?branch=main)\n\n\n[//]: # (::contents:start)\n\n## Usage\n\nFirst, require me where you could throw errors:\n\n```js\nimport YError from 'yerror';\n```\n\nThen, emit errors with a bonus: parameters!\n\n```js\nfunction doSomething(pay, action) {\n  if(parseInt(pay, 10) !== pay) {\n    throw new YError('E_BAD_PAY', pay, action);\n  }\n}\n\ndoSomething('nuts', 'code');\n\n\n// YError: E_BAD_PAY (nuts, code)\n//   at doSomething (/home/nfroidure/nfroidure/yerror/test.js:5:11)\n//   at Object.<anonymous> (/home/nfroidure/nfroidure/yerror/test.js:9:1)\n//   (...)\n```\n\nYou don't have to use constant like error messages, we use this convention\nmainly for i18n reasons.\n\nAlso, you could want to wrap errors and keep a valuable stack trace:\n\n```js\nfunction doSomethingAsync(pay, action) {\n  return  new Promise(function(resolve, reject) {\n    try {\n      doSomething(pay, action);\n      resolve();\n    } catch(err) {\n      reject(YError.bump(err));\n    }\n  });\n}\n\ndoSomethingAsync('nuts', 'code')\n  .catch(function(err) {\n    console.log(err.stack);\n  });\n\n// YError: E_BAD_PAY (nuts, code)\n//    at doSomething (/home/nfroidure/nfroidure/yerror/test.js:5:11)\n//    (...)\n// YError: E_BAD_TRANSACTION (pay)\n//    at Function.YError.wrap (/home/nfroidure/nfroidure/yerror/src/index.js:41:12)\n//    at /home/nfroidure/nfroidure/yerror/test.js:16:21\n//    at doSomethingAsync (/home/nfroidure/nfroidure/yerror/test.js:11:11)\n//    (...)\n```\n\n\n[//]: # (::contents:end)\n\n# API\n## Classes\n\n<dl>\n<dt><a href=\"#YError\">YError</a> ⇐ <code>Error</code></dt>\n<dd><p>A YError class able to contain some params and\n print better stack traces</p>\n</dd>\n</dl>\n\n## Functions\n\n<dl>\n<dt><a href=\"#printStackTrace\">printStackTrace(err)</a> ⇒ <code>string</code></dt>\n<dd><p>Allow to print a stack from anything (especially catched\n errors that may or may not contain errors 🤷).</p>\n</dd>\n</dl>\n\n<a name=\"YError\"></a>\n\n## YError ⇐ <code>Error</code>\nA YError class able to contain some params and\n print better stack traces\n\n**Kind**: global class  \n**Extends**: <code>Error</code>  \n\n* [YError](#YError) ⇐ <code>Error</code>\n    * [.wrap(err, [errorCode], [...params])](#YError.wrap) ⇒ [<code>YError</code>](#YError)\n    * [.cast(err, [errorCode], [...params])](#YError.cast) ⇒ [<code>YError</code>](#YError)\n    * [.bump(err, [errorCode], [...params])](#YError.bump) ⇒ [<code>YError</code>](#YError)\n\n<a name=\"YError.wrap\"></a>\n\n### YError.wrap(err, [errorCode], [...params]) ⇒ [<code>YError</code>](#YError)\nWraps any error and output a YError with an error\n code and some params as debug values.\n\n**Kind**: static method of [<code>YError</code>](#YError)  \n**Returns**: [<code>YError</code>](#YError) - The wrapped error  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| err | <code>Error</code> |  | The error to wrap |\n| [errorCode] | <code>string</code> | <code>&quot;&#x27;E_UNEXPECTED&#x27;&quot;</code> | The error code corresponding to the actual error |\n| [...params] | <code>YErrorParams</code> |  | Some additional debugging values |\n\n<a name=\"YError.cast\"></a>\n\n### YError.cast(err, [errorCode], [...params]) ⇒ [<code>YError</code>](#YError)\nReturn a YError as is or wraps any other error and output\n a YError with a code and some params as debug values.\n\n**Kind**: static method of [<code>YError</code>](#YError)  \n**Returns**: [<code>YError</code>](#YError) - The wrapped error  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| err | <code>Error</code> |  | The error to cast |\n| [errorCode] | <code>string</code> | <code>&quot;&#x27;E_UNEXPECTED&#x27;&quot;</code> | The error code corresponding to the actual error |\n| [...params] | <code>YErrorParams</code> |  | Some additional debugging values |\n\n<a name=\"YError.bump\"></a>\n\n### YError.bump(err, [errorCode], [...params]) ⇒ [<code>YError</code>](#YError)\nSame than `YError.wrap()` but preserves the code\n and the debug values of the error if it is\n already an instance of the YError constructor.\n\n**Kind**: static method of [<code>YError</code>](#YError)  \n**Returns**: [<code>YError</code>](#YError) - The wrapped error  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| err | <code>Error</code> |  | The error to bump |\n| [errorCode] | <code>string</code> | <code>&quot;&#x27;E_UNEXPECTED&#x27;&quot;</code> | The error code corresponding to the actual error |\n| [...params] | <code>YErrorParams</code> |  | Some additional debugging values |\n\n<a name=\"printStackTrace\"></a>\n\n## printStackTrace(err) ⇒ <code>string</code>\nAllow to print a stack from anything (especially catched\n errors that may or may not contain errors 🤷).\n\n**Kind**: global function  \n**Returns**: <code>string</code> - The stack trace if any  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| err | <code>Error</code> | The error to print |\n\n\n# Authors\n- [Nicolas Froidure (formerly at SimpliField)](http://insertafter.com/en/index.html)\n\n# License\n[MIT](https://github.com/nfroidure/yerror/blob/main/LICENSE)\n","publish_time":1549094067658,"_cnpm_publish_time":1549094067658,"dist-tags":{"latest":"11.0.0"}}