{"_id":"errorifier","_rev":"6581","name":"errorifier","description":"Creates Error uniformly.","dist-tags":{"latest":"0.2.0"},"maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"time":{"modified":"2021-06-03T09:56:57.000Z","created":"2015-07-26T11:30:37.005Z","0.2.0":"2015-10-01T23:33:46.791Z","0.1.3":"2015-07-28T18:47:03.944Z","0.1.2":"2015-07-28T18:19:43.698Z","0.1.0":"2015-07-26T11:30:37.005Z"},"users":{},"author":{"name":"Kiko Beats","email":"josefrancisco.verdu@gmail.com","url":"https://github.com/Kikobeats"},"repository":{"type":"git","url":"https://github.com/Kikobeats/errorifier"},"versions":{"0.2.0":{"name":"errorifier","description":"Creates Error uniformly.","homepage":"https://github.com/Kikobeats/errorifier","version":"0.2.0","main":"./index.js","author":{"name":"Kiko Beats","email":"josefrancisco.verdu@gmail.com","url":"https://github.com/Kikobeats"},"repository":{"type":"git","url":"https://github.com/Kikobeats/errorifier"},"bugs":{"url":"https://github.com/Kikobeats/errorifier/issues"},"keywords":["custom","error","factory","throw"],"dependencies":{"coffee-script":"~1.10.0","format":"~0.2.1"},"devDependencies":{"browserify":"*","coffeeify":"*","gulp":"*","gulp-header":"*","gulp-uglify":"*","gulp-util":"*","mocha":"*","should":"*","vinyl-buffer":"*","vinyl-source-stream":"*"},"engines":{"node":">= 0.10.0","npm":">= 1.4.0"},"scripts":{"test":"sh test/test.sh"},"license":"MIT","gitHead":"aff1849ebac5f339a3140080c73bf4861ee4bbf1","_id":"errorifier@0.2.0","_shasum":"a1245ec200a5326835b9dc29fd9bc92cd010ccf3","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"dist":{"shasum":"a1245ec200a5326835b9dc29fd9bc92cd010ccf3","size":7256,"noattachment":false,"key":"/errorifier/-/errorifier-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/errorifier/download/errorifier-0.2.0.tgz"},"maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"directories":{},"publish_time":1443742426791,"_cnpm_publish_time":1443742426791,"_hasShrinkwrap":false},"0.1.3":{"name":"errorifier","description":"Creates Error uniformly.","homepage":"https://github.com/Kikobeats/errorifier","version":"0.1.3","main":"./index.js","author":{"name":"Kiko Beats","email":"josefrancisco.verdu@gmail.com","url":"https://github.com/Kikobeats"},"repository":{"type":"git","url":"https://github.com/Kikobeats/errorifier"},"bugs":{"url":"https://github.com/Kikobeats/errorifier/issues"},"keywords":["custom","error","factory","throw"],"dependencies":{"coffee-script":"~1.9.3"},"devDependencies":{"browserify":"*","coffeeify":"*","gulp":"*","gulp-header":"*","gulp-uglify":"*","gulp-util":"*","mocha":"*","should":"*","vinyl-buffer":"*","vinyl-source-stream":"*"},"engines":{"node":">= 0.10.0","npm":">= 1.4.0"},"scripts":{"test":"sh test/test.sh"},"license":"MIT","gitHead":"e0de222060301e876ccd6e9e39c4c4ddc68a593c","_id":"errorifier@0.1.3","_shasum":"c8928d5f2c9818acd5c9bfae8a109c07e8fbd3c4","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"dist":{"shasum":"c8928d5f2c9818acd5c9bfae8a109c07e8fbd3c4","size":6679,"noattachment":false,"key":"/errorifier/-/errorifier-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/errorifier/download/errorifier-0.1.3.tgz"},"maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"directories":{},"publish_time":1438109223944,"_cnpm_publish_time":1438109223944,"_hasShrinkwrap":false},"0.1.2":{"name":"errorifier","description":"Creates Error uniformly.","homepage":"https://github.com/Kikobeats/errorifier","version":"0.1.2","main":"./index.js","author":{"name":"Kiko Beats","email":"josefrancisco.verdu@gmail.com","url":"https://github.com/Kikobeats"},"repository":{"type":"git","url":"https://github.com/Kikobeats/errorifier"},"bugs":{"url":"https://github.com/Kikobeats/errorifier/issues"},"keywords":["custom","error","factory","throw"],"dependencies":{"coffee-script":"~1.9.3"},"devDependencies":{"browserify":"*","coffee-script":"*","coffeeify":"*","gulp":"*","gulp-header":"*","gulp-uglify":"*","gulp-util":"*","mocha":"*","should":"*","vinyl-buffer":"*","vinyl-source-stream":"*"},"engines":{"node":">= 0.10.0","npm":">= 1.4.0"},"scripts":{"test":"sh test/test.sh"},"license":"MIT","gitHead":"7273df6c56d1bd832107a28ebf85f2d17d1a93ce","_id":"errorifier@0.1.2","_shasum":"19c823493a548a13fb19da96476498bcb9f2b058","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"dist":{"shasum":"19c823493a548a13fb19da96476498bcb9f2b058","size":6618,"noattachment":false,"key":"/errorifier/-/errorifier-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/errorifier/download/errorifier-0.1.2.tgz"},"maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"directories":{},"publish_time":1438107583698,"_cnpm_publish_time":1438107583698,"_hasShrinkwrap":false},"0.1.0":{"name":"errorifier","description":"Creates Error uniformly.","homepage":"https://github.com/Kikobeats/errorifier","version":"0.1.0","main":"./index.js","author":{"name":"Kiko Beats","email":"josefrancisco.verdu@gmail.com","url":"https://github.com/Kikobeats"},"repository":{"type":"git","url":"git+https://github.com/kikobeats/errorifier.git"},"bugs":{"url":"https://github.com/Kikobeats/errorifier/issues"},"keywords":["custom","error","factory","throw"],"dependencies":{},"devDependencies":{"browserify":"*","coffee-script":"*","coffeeify":"*","gulp":"*","gulp-header":"*","gulp-uglify":"*","gulp-util":"*","mocha":"*","should":"*","vinyl-buffer":"*","vinyl-source-stream":"*"},"engines":{"node":">= 0.10.0","npm":">= 1.4.0"},"scripts":{"test":"sh test/test.sh"},"license":"MIT","gitHead":"594c110c059016150d922fdfcac6556aa4421ae1","_id":"errorifier@0.1.0","_shasum":"9403ebc1903586e725c38c44e21d19489f135191","_from":".","_npmVersion":"2.13.1","_nodeVersion":"0.10.39","_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"dist":{"shasum":"9403ebc1903586e725c38c44e21d19489f135191","size":6550,"noattachment":false,"key":"/errorifier/-/errorifier-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/errorifier/download/errorifier-0.1.0.tgz"},"maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"directories":{},"publish_time":1437910237005,"_cnpm_publish_time":1437910237005,"_hasShrinkwrap":false}},"readme":"# Errorifier\n\n![Last version](https://img.shields.io/github/tag/Kikobeats/errorifier.svg?style=flat-square)\n[![Dependency status](http://img.shields.io/david/Kikobeats/errorifier.svg?style=flat-square)](https://david-dm.org/Kikobeats/errorifier)\n[![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/errorifier.svg?style=flat-square)](https://david-dm.org/Kikobeats/errorifier#info=devDependencies)\n[![NPM Status](http://img.shields.io/npm/dm/errorifier.svg?style=flat-square)](https://www.npmjs.org/package/errorifier)\n[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/kikobeats)\n\n> Adopting an uniform errors policy based in NodeJS errors schema.\n\n## Why\n\n- An easy way to create qualified errors.\n- Using the standard Error interface in browser and NodeJS.\n- Attach extra information, depending of your case of use.\n\nThe native `Error` global object in JavaScript is broken. It is different depending of your browser of your environment.\n\nI feel that [standard NodeJS Errors](https://github.com/rvagg/node-errno) are more powerful: this follow the same format. For example, if you try to read a file that doesn't exist you have the follow error:\n\n```js\nfs.readFile('filename', function(err, data) {\n  console.log(err);\n  // { [Error: ENOENT, open 'filename']\n  //   errno: 34,\n  //   code: 'ENOENT',\n  //   path: 'filename' }\n});\n\n```\n\nThe `error` have a `code` that is useful because it's part of the output message. If you try to print the error:\n\n```\nconsole.log(err.message);\n// => ENOENT, open 'filename'\n```\n\nThis library pretend extend NodeJS standard error for whatever error that you need to create.\n\n## Install\n\n```bash\nnpm install errorifier --save\n```\n\nIf you want to use in the browser (powered by [Browserify](http://browserify.org/)):\n\n```bash\nbower install errorifier --save\n```\n\nand later link in your HTML:\n\n```html\n<script src=\"bower_components/errorifier/dist/errorifier.js\"></script>\n```\n\n## Usage\n\nLoad the constructor as a common NodeJS dependency:\n\n```js\nvar Errorifier = require('errorifier');\n```\n\nNow, the next time that you need an error you have two ways to create.\n\nIf you don't need to specify to many things associated with the error, you can create it inline mode. Just provide the error type and the description as string:\n\n```js\nthrow new Errorifier('NotValidJSON, The format of the JSON is invalid');\n```\n\nThis will print the error and the stack trace:\n\n```bash\nError: NotValidJSON, The format of the JSON is invalid\n  at new Errorifier (/Users/josefranciscoverdugambin/Projects/errorifier/lib/Errorifier.coffee:6:17)\n  at Object.<anonymous> (/Users/josefranciscoverdugambin/Projects/errorifier/example.js:3:7)\n  at Module._compile (module.js:456:26)\n  at Object.Module._extensions..js (module.js:474:10)\n  at Module.load (module.js:356:32)\n  at Function.Module._load (module.js:312:12)\n  at Function.Module.runMain (module.js:497:10)\n  at startup (node.js:119:16)\n  at node.js:935:3\n```\n\nIf you need to associate whatever thing with the error, you can use the Object param format:\n\n```js\nthrow new Errorifier({\n  code: 'NotValidJSON',\n  message: 'The format of the JSON is invalid',\n  errno: 127,\n  foo: 'bar'\n});\n```\n\nThis prints the same as the inline mode, but you can store whatever thing (as `errno` or `foo` in this case) with the error.\n\n## Always return an Error object\n\nIf you code implementation is **synchronous**, return `Error` object under unexpected behaviors.\n\nIf you code implementation is **asynchronous**, return `Error` object under unexpected behaviors as well!\n\nIt's correct returns a object in a callback to express a unexpected behavior, but the object doesn't have a type and definetly doesn't follow a error interface:\n\n```js\ncallback('LOL something was wrong'); // poor\ncallback({message: 'LOL something was wrong' } // poor, but better\ncallback(new Errorifier('LOL, something was wrong') // BEST!\n```\n\nNow you can associated different type of error with different behavior.\n\n```js\nswitch (err.code) {\n  case 'LOL':\n    console.log('your error logic here');\n    break;\n  default:\n    console.log('undefined code');\n    break;\n};\n```\n\n## License\n\nMIT © [Kiko Beats](http://www.kikobeats.com)\n","_attachments":{},"homepage":"https://github.com/Kikobeats/errorifier","bugs":{"url":"https://github.com/Kikobeats/errorifier/issues"},"license":"MIT"}