Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial Commit

  • Loading branch information...
commit 6049d50016d59de83b849f57beefcd6bd612e7a8 0 parents
Steve Regester authored
Showing with 65 additions and 0 deletions.
  1. 0  README.md
  2. +47 −0 http-errors.js
  3. +18 −0 package.json
0  README.md
No changes.
47 http-errors.js
@@ -0,0 +1,47 @@
+var errorMap = {
+ 400: 'Bad request',
+ 401: 'Unauthorized',
+ 402: 'Payment Required',
+ 403: 'Forbidden',
+ 404: 'Not found',
+ 405: 'Not Allowed',
+ 406: 'Not Acceptable',
+ 407: 'Proxy Authentication Required',
+ 408: 'Request Timeout',
+ 409: 'Resource Conflict',
+ 410: 'Resource Gone',
+ 411: 'Length Required',
+ 412: 'Precondition Failed',
+ 413: 'Request Entity Too Large',
+ 414: 'Request-URI Too Long',
+ 415: 'Unsupported Media Type',
+ 416: 'Requested Range Not Satisfiable',
+ 417: 'Expectation Failed',
+ 418: 'I\'m a teapot',
+ 420: 'Enhance Your Calm',
+ 428: 'Precondition Required',
+ 429: 'Too Many Requests',
+ 431: 'Request Header Fields Too Large',
+ 500: 'Server error',
+ 501: 'Not Implemented',
+ 502: 'Bad Gateway',
+ 503: 'Service Unavailable',
+ 504: 'Gateway Timeout',
+ 505: 'HTTP Version Not Supported',
+ 506: 'Variant Also Negotiates',
+ 511: 'Network Authentication Required'
+}
+
+var HTTPErrors = {}
+
+for (var status in errorMap) {
+ var message = errorMap[status]
+ , HTTPError = function() { Error.apply(this, arguments) }
+ HTTPError.prototype = new Error
+ HTTPError.prototype.status = status
+ HTTPError.prototype.message = message
+ HTTPError.prototype.constructor = HTTPError
+ HTTPErrors[status] = HTTPError
+}
+
+module.exports = HTTPErrors
18 package.json
@@ -0,0 +1,18 @@
+{
+ "name": "http-errors",
+ "description": "A node module that returns a hash of Error classes representing HTTP errors indexed by error code.",
+ "url": "https://github.com/egeste/http-errors",
+ "keywords": ["util", "errors", "http"],
+ "author": {
+ "name": "Steve (Egesté) Regester",
+ "email": "npm@egeste.net"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/egeste/http-errors.git"
+ },
+ "main": "http-errors.js",
+ "version": "0.0.1",
+ "engines": { "node": "*" },
+ "_engineSupported": true
+}
Please sign in to comment.
Something went wrong with that request. Please try again.