{"_id":"httperr","_rev":"37-f595c2a64438847c15e99f3e8534f5a8","name":"httperr","description":"HTTP status codes as JavaScript errors.","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"httperr","version":"0.1.0","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{},"license":"MIT","main":"index.js","scripts":{},"engines":{"node":">=0.6"},"_id":"httperr@0.1.0","dist":{"shasum":"8a4ff8e97f8c39f8bf987e89e68f0e102026d9b7","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.1.0.tgz","integrity":"sha512-CQwGjPkadc5qED/zRW/wE8bOmOdceYJReEVx7Qxo9mbhMN80bD1v5kQbJnRrf1VIcEmTjSvCXHOJZdsAPn5+iA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDj1uEi1aUzh4mvHk7Cp10/kzuFs2gil/FQAwBK2uxSDwIhALn/sdBAYghKl0zEPLCWSj1s6ehVVjsHXdKfYXcwM9T1"}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}],"directories":{}},"0.1.1":{"name":"httperr","version":"0.1.1","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{},"license":"MIT","main":"index.js","scripts":{},"engines":{"node":">=0.6"},"_id":"httperr@0.1.1","dist":{"shasum":"678713e41f550402dcb8d6e920d69307e5331949","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.1.1.tgz","integrity":"sha512-lzSPyb+0PRXPJD4NvYA76+PTCUoprblCHXXIAZu5X4UEqXClpj4cTBwFM4APYYdHh+qeAd6c8H5O/TiXSaM/BA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA8hRtez1DcnP0yZZw5KIPtctlVUF9m0YShfFeZBQ6x7AiEAiFnCARnrJ9/3nTJSrpXHsNxMlsRGuZUjZh4xVGVT3Nw="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}],"directories":{}},"0.1.2":{"name":"httperr","version":"0.1.2","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{},"license":"MIT","main":"index.js","scripts":{},"engines":{"node":">=0.6"},"_id":"httperr@0.1.2","dist":{"shasum":"a3b369a00225f4c6bab7a2a90bff856e0f2e0afc","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.1.2.tgz","integrity":"sha512-4YRRAL/8eDru2z1kPF9bvrAWG4BRT1weUCSwfoh8T9FVA7L12fTdhAli90WaRQzlN+qwYnV2wmpmzblF1iz0Cw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD3IsKTQdhvGlXDr+rMG3u0BrH3Rj2dx7vuLDuyi+LV7gIgCI47bOVa1D6EMpUqKJ/6JFFEsfqlv0BtsPvkbspXmLM="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}],"directories":{}},"0.1.3":{"name":"httperr","version":"0.1.3","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{},"license":"MIT","main":"index.js","scripts":{},"engines":{"node":">=0.6"},"_id":"httperr@0.1.3","dist":{"shasum":"caf92d67d69c9986a9e3a3546ba40380c9f9ba9a","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.1.3.tgz","integrity":"sha512-04+DQtqhB2AyvKYJyTFhfrR30U+trsHJ5rBkcMML01hsP6hbbbXacZWOKRxV5zcccac+s73GHJRy50mpDPk0wQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeAsoem31Z3egLE4MpN5Ni5gjRvGrkjVXyurUmS2akKAIgCZ0M6tzAgvLte3k7u5FutJxvEPD0crpPV6iHg2rk/p0="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}],"directories":{}},"0.2.0":{"name":"httperr","version":"0.2.0","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{},"license":"MIT","main":"index.js","scripts":{},"engines":{"node":">=0.6"},"_id":"httperr@0.2.0","dist":{"shasum":"2efab4925358c1f751a548f39cea3c2540f0c5a9","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.2.0.tgz","integrity":"sha512-NeuLr4zVN3sKFDRCWohXXAhNzt3D33szPyJ0YvbIQvcL+Ox7dlABr9MDuFaOdaQUWuKcodGpPdvZMGgeLPy1zg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDH9UX/UQEK6a4hFNoMGYMfbcyIrn/486A1k+zdmmwzyQIgK9lyTBZ9aY2vPJpR43ndLka1DRUPvtIOd/2muel2B+c="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}]},"0.3.0":{"name":"httperr","version":"0.3.0","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","licenses":{"type":"UNLICENSE","url":"https://github.com/pluma/httperr/blob/master/UNLICENSE"},"repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{},"main":"index.js","scripts":{},"engines":{"node":">=0.6"},"_id":"httperr@0.3.0","dist":{"shasum":"b84a7d69d9ada51ac7d3650d417e8a1c21ceccdf","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.3.0.tgz","integrity":"sha512-a5CD64BXnaxSHbkeqRSVlw6MTiGkobox7LWyeUxmIvxxlqwvgDhIQhNG4Fs87iC+CJEEEAkC5ANsdvSodQ/q0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7vdvjlo0u4wYyOW6m5XedH+N13b16vloeaIYwp0+M2gIgLIsV+y4KJ0b9oesX8YxmT/lZ4LmopisWw2D1SwzA94c="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}]},"0.4.0":{"name":"httperr","version":"0.4.0","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","licenses":{"type":"UNLICENSE","url":"https://github.com/pluma/httperr/blob/master/UNLICENSE"},"repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{"mocha":"~1.17","expect.js":"~0.2","jshint":"~2.4","istanbul":"~0.2","coveralls":"~2.6","rewire":"~2.0"},"main":"index.js","scripts":{"test":"make test","coveralls":"make coveralls"},"engines":{"node":">=0.6"},"_id":"httperr@0.4.0","dist":{"shasum":"31bcc5526b2ebc778d2d08ec32807cbdc698c863","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.4.0.tgz","integrity":"sha512-z1SV0GF5qomucJqraGWIc1PKPPAGDm5+GbBamUTIXQRIXFXEWgHK4WEHmkzV5hqDwkeIdaYs3QTSlccXHUiYRQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFJa5vGiqVz3pAFePSuJBTC+qfg/6pa2qC+iakREhYHXAiBgj5e/W1ZmOPdvrITh4G8QW7uJSx0DWMnenxawBALoaA=="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}]},"0.5.0":{"name":"httperr","version":"0.5.0","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","licenses":{"type":"UNLICENSE","url":"https://github.com/pluma/httperr/blob/master/UNLICENSE"},"repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{"mocha":"~1.17","expect.js":"~0.2","jshint":"~2.4","istanbul":"~0.2","coveralls":"~2.6","rewire":"~2.0"},"main":"index.js","scripts":{"test":"make test","coveralls":"make coveralls"},"engines":{"node":">=0.6"},"bugs":{"url":"https://github.com/pluma/httperr/issues"},"homepage":"https://github.com/pluma/httperr","_id":"httperr@0.5.0","dist":{"shasum":"fdd7d4ee22db0ab5ddb68ce286dea40038114853","tarball":"https://registry.npmjs.org/httperr/-/httperr-0.5.0.tgz","integrity":"sha512-88W4q4tPV7d8J5Lzp1nXEOkp391YE5WUPguOAp7rWBmgr397DghGkpBbBXj7NV3jLeyOnOgykzCDwNBsgPhmbw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIClbASV9D4FxlhNev8D5c73a7nFM8Pk1Q29BgeqcWuauAiBqOJVze3htV9DUV4ctIurp/YZoxX/TGNC3iBjueWXSjw=="}]},"_from":".","_npmVersion":"1.4.6","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}]},"1.0.0":{"name":"httperr","version":"1.0.0","author":{"name":"Alan Plum","email":"me@pluma.io"},"description":"HTTP status codes as JavaScript errors.","licenses":{"type":"UNLICENSE","url":"https://github.com/pluma/httperr/blob/master/UNLICENSE"},"repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"keywords":["http","errors","error","request","response","errorclass"],"dependencies":{},"devDependencies":{"mocha":"~1.21","expect.js":"~0.3","jshint":"~2.5","istanbul":"~0.3","coveralls":"~2.11","rewire":"~2.1"},"main":"index.js","scripts":{"test":"make test","coveralls":"make coveralls"},"engines":{"node":">=0.6"},"gitHead":"1495effb0c54b0e4d9fd4618a51741ebd0c0089c","bugs":{"url":"https://github.com/pluma/httperr/issues"},"homepage":"https://github.com/pluma/httperr","_id":"httperr@1.0.0","_shasum":"6204cc0961825e9e7f39c9bb3975451cfb9ee216","_from":".","_npmVersion":"1.4.24","_npmUser":{"name":"pluma","email":"me@pluma.io"},"maintainers":[{"name":"pluma","email":"me@pluma.io"}],"dist":{"shasum":"6204cc0961825e9e7f39c9bb3975451cfb9ee216","tarball":"https://registry.npmjs.org/httperr/-/httperr-1.0.0.tgz","integrity":"sha512-lyydMvey//cE2zJyn3ig0s5Ms7RIGlBDEtSDM4cGWaejVSU66AyqAv04vDowSZkhkyVlDU9/7M4oFkM2wUlWBQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVScFe4g92hH0IPoXHfC5pcHJAfzh3OpQKAEluIq06owIhAKulBBoUsybzl1Pt4rvwrREew3YgC5MXrw9jXTZ+4h5A"}]}}},"readme":"# Synopsis\n\n**httperr** provides Error types for all HTTP error status codes.\n\n[![stability 3 - stable](http://b.repl.ca/v1/stability-3_--_stable-yellowgreen.png)\n](http://nodejs.org/api/documentation.html#documentation_stability_index) [![license - Unlicense](http://b.repl.ca/v1/license-Unlicense-lightgrey.png)](http://unlicense.org/) [![Flattr this](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=pluma&url=https://github.com/pluma/httperr)\n\n[![Build Status](https://travis-ci.org/pluma/httperr.png?branch=master)](https://travis-ci.org/pluma/httperr) [![Coverage Status](https://coveralls.io/repos/pluma/httperr/badge.png?branch=master)](https://coveralls.io/r/pluma/httperr?branch=master) [![Dependencies](https://david-dm.org/pluma/httperr.png?theme=shields.io)](https://david-dm.org/pluma/httperr)\n\n[![NPM status](https://nodei.co/npm/httperr.png?compact=true)](https://npmjs.org/package/httperr)\n\n# Why?\n\nThere are several libraries that already do this, but most of them either only support a very limited number of status codes, don't capture stack traces correctly or are no longer maintained.\n\nThe biggest difference in **httperr** is that it lets you attach relevant information for the error in a single function call, allowing you to separate your error handling and error response logic without losing the semantics of HTTP status codes.\n\n# Install\n\n## With NPM\n\n```sh\nnpm install httperr\n```\n\n## From source\n\n```sh\ngit clone https://github.com/pluma/httperr.git\ncd httperr\nnpm install\n```\n\n# Basic usage example\n\n```javascript\nvar httperr = require('httperr');\n\nvar err = httperr[404]('The path \"/example\" could not be resolved');\nconsole.log(err);\n/*\n{ [NotFound: The path \"/example\" could not be resolved]\n  title: 'Not Found',\n  name: 'NotFound',\n  code: 'NOT_FOUND',\n  statusCode: 404,\n  message: 'The path \"/example\" could not be resolved'\n}\n*/\nthrow err;\n/*\nNotFound: The path \"/example\" could not be resolved\n    at ...\n*/\n\nconsole.log(httperr.methodNotAllowed({allowed: ['GET', 'POST']}));\n/*\n{ [MethodNotAllowed]\n  title: 'Method Not Allowed',\n  name: 'MethodNotAllowed',\n  code: 'METHOD_NOT_ALLOWED',\n  statusCode: 405,\n  message: '',\n  allowed: ['GET', 'POST']\n}\n*/\n\nerr = new httperr.NotFound();\nconsole.log(err);\n/*\n{ [NotFound]\n  title: 'Not Found',\n  name: 'NotFound',\n  code: 'NOT_FOUND',\n  statusCode: 404,\n  message: 'The path \"/example\" could not be resolved'\n}\n*/\n\nconsole.log(err instanceof httperr.NotFound); // true\nconsole.log(err instanceof httperr.notFound); // true\nconsole.log(err instanceof httperr['404']); // true\nconsole.log(err instanceof httperr.MethodNotAllowed); // false\nconsole.log(err instanceof httperr.HttpError); // true\nconsole.log(err instanceof Error); // true\n```\n\n# API\n\n## new httperr.{ErrorName}([config, [extra:Object]]):Error\n\nCreates an Error object. The `new` keyword is optional.\n\nExample:\n\n```javascript\nnew httperr.NotFound({message: 'That does not exist'});\n```\n\nIf `extra` is given and is an object, its properties will be copied to the new Error object before `config` is applied.\n\nIf `config` is a string, it will be treated as `config.message`.\n\nIf `config` is an `Error` object, it will be treated as `config.cause`.\n\nIf `config` is an object, it can have the following properties:\n\n### config.message (optional)\nA descriptive human-readable title describing the error's cause.\n\n### config.cause (optional)\nThe underlying exception that caused the HTTP error.\n\n### config.details (optional)\nA detailed human-readable description of the error's cause and possible solutions.\n\n### config.allowed (optional)\nThe methods allowed for this URL.\n\nThis property is only available for `405 Method Not Allowed` errors and can be used to populate the `Allow` header.\n\n### config.retryAfter (optional)\nThe minimum delay before the request should be attempted again.\n\nThis property is only available for `429 Too Many Requests` and `420 Enhance Your Calm` (Twitter API) errors and can be used to populate the `Retry-After` header.\n\n### config.parameters (optional)\nThe parameters with which the request should be retried.\n\nThis property is only available for `449 Retry With` (Microsoft) errors and can be used to populate the response status message.\n\n### config.location (optional)\nThe location for which the request should be repeated.\n\nThis property is only available for `451 Redirect` (Microsoft) errors and can be used to populate the proprietary `X-MS-Location` response header.\n\n## httperr.{statusCode}([config, [extra:Object]]):Error\n\nSee above.\n\nExample:\n\n```javascript\nhttperr[404]({message: 'That does not exist either'});\n```\n\n## httperr.{errorName}([config, [extra:Object]]):Error\n\nSee above.\n\nExample:\n\n```javascript\nhttperr.notFound({message: 'This link is dead, too'})\n```\n\n## httperr.createHttpError(status:Number, title:String, [init:Function]):Function\nCreates a new error type for the given HTTP error status.\n\nTakes the following arguments:\n\n### title\nA human-readable title for the HTTP error.\n\n### status\nThe HTTP response status code for the HTTP error.\n\n### init (optional)\nA function which will be invoked as a method of the new error with the `config` argument immediately after the error is created by the factory. Can be used to process additional error-specific configuration parameters.\n\n## new httperr.HttpError(config)\n\nThe base type for all `httperr` error types. You probably don't want to use this directly.\n\n## httperr.HttpError::toObject([skip…]):Object\n\nReturns a JSON serializable representation of this `httperr` error (including any nested `Error` objects).\n\nTakes the following arguments:\n\n### skip (optional)\n\nOne or more strings or regular expressions against which the property names of `Error` objects including `httperr` errors will be matched. Any matching properties will not be copied to the returned object.\n\nExample:\n\n```js\nvar err = httperr.notFound('File Not Found');\nconsole.log(err.toObject());\n/*\n{\n  name: 'NotFound',\n  code: 'NOT_FOUND',\n  title: 'Not Found',\n  statusCode: 404,\n  message: 'File Not Found',\n  stack: '…'\n}\n*/\nconsole.log(err.toObject('stack', /^title$/));\n/*\n{\n  name: 'NotFound',\n  code: 'NOT_FOUND',\n  statusCode: 404,\n  message: 'File Not Found'\n}\n*/\n```\n\n# Unlicense\n\nThis is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying [UNLICENSE](https://github.com/pluma/httperr/blob/master/UNLICENSE) file.\n","maintainers":[{"name":"pluma","email":"me@pluma.io"}],"time":{"modified":"2022-06-18T22:20:02.230Z","created":"2013-12-29T13:03:52.521Z","0.1.0":"2013-12-29T13:03:55.663Z","0.1.1":"2013-12-30T17:41:44.401Z","0.1.2":"2013-12-30T18:04:05.735Z","0.1.3":"2013-12-30T19:26:16.382Z","0.2.0":"2014-01-14T01:32:59.022Z","0.3.0":"2014-01-23T00:05:30.585Z","0.4.0":"2014-01-24T20:15:25.638Z","0.5.0":"2014-05-05T10:44:26.524Z","1.0.0":"2014-09-13T17:57:22.781Z"},"author":{"name":"Alan Plum","email":"me@pluma.io"},"repository":{"type":"git","url":"https://github.com/pluma/httperr.git"},"readmeFilename":"README.md","homepage":"https://github.com/pluma/httperr","keywords":["http","errors","error","request","response","errorclass"],"bugs":{"url":"https://github.com/pluma/httperr/issues"},"users":{"timhudson":true}}