{
  "author": {
    "name": "Isaac Z. Schlueter",
    "email": "i@izs.me",
    "url": "http://blog.izs.me/"
  },
  "name": "error-page",
  "description": "Easily send errors in Node.js HTTP servers. Think like the `ErrorDocument` declarations in Apache config files.",
  "version": "0.0.6",
  "repository": {
    "type": "git",
    "url": "git://github.com/isaacs/error-page.git"
  },
  "main": "error-page.js",
  "scripts": {
    "test": "tap test/*.js"
  },
  "dependencies": {},
  "devDependencies": {
    "ejs": "~0.7.1",
    "templar": "0.0.4",
    "tap": "~0.2.4",
    "request": "~2.9.202"
  },
  "optionalDependencies": {},
  "engines": {
    "node": "*"
  },
  "readme": "# error-page\n\nEasily send errors in Node.js HTTP servers.\n\nThink like the `ErrorDocument` declarations in Apache config files.\n\n## Usage\n\n```javascript\nvar ErrorPage = require('error-page')\n\nhttp.createServer(function (req, res) {\n  // returns a function that we use to send error responses\n  res.error = ErrorPage(req, res, { // options\n    404: the404HandlerFunction,\n    5xx: handleAll500s,\n    403: 'forbidden.ejs', // template name integrates with Templar\n    400: 'that was bad', // other strings just print out as-is\n    \"*\": handleEverythingElse\n    debug: false // show full stack traces, or just messages\n  })\n\n  // .. some time later ..\n  // .. we've decided that the page doesn't exist ..\n  return res.error(404)\n\n  // or maybe we decided that the request method is no good...\n  // Give a little extra bit on the message.\n  return res.error(405, \"Allowed methods: GET, POST, HEAD\")\n\n  // or maybe they just need to try again in 10 seconds\n  return res.error(503, {'retry-after':10})\n\n  // or maybe we are a teapot\n  return res.error(418)\n\n  // or maybe something threw\n  try {\n    blerg()\n  } catch (er) {\n    return res.error(er)\n  }\n})\n```\n\nAny arguments to the `res.error` function will be interpreted based on\ntheir type:\n\n* Number: the status code (defaults to 500, if it can't find one)\n* Error object: Some error that was thrown or raised somewhere (with a\n  stack, etc.)\n* Other object: Bag o' headers which get set on the response.\n* Function: A handler to use, instead of the one set up initially\n* String: If there's a `res.template` from\n  [Templar](https://github.com/isaacs/templar), and it's a valid\n  template name, then it'll use the template as the handler.\n* String that is not a template: A message (defaults to the `message`\n  property on the Error object, if one was supplied, or the default\n  message associated with the status code.)\n\nThe handler (or template) is called with the request and response\nobjects, and a `data` object containing:\n\n```javascript\ndata = { message: message\n       , code: code\n       , statusCode: code\n       , error: er\n       , options: opts\n       , request: req.method + ' ' + req.url\n       , headers: req.headers\n       , url: req.url\n       }\n```\n",
  "_id": "error-page@0.0.6",
  "_from": "error-page@0"
}
