{
  "name": "error-ex",
  "description": "Easy error subclassing and stack customization",
  "version": "1.2.0",
  "maintainers": [
    {
      "name": "JD Ballard",
      "email": "i.am.qix@gmail.com",
      "url": "github.com/qix-"
    },
    {
      "name": "Sindre Sorhus",
      "email": "sindresorhus@gmail.com",
      "url": "sindresorhus.com"
    }
  ],
  "keywords": [
    "error",
    "errors",
    "extend",
    "extending",
    "extension",
    "subclass",
    "stack",
    "custom"
  ],
  "license": "MIT",
  "scripts": {
    "pretest": "xo",
    "test": "mocha --compilers coffee:coffee-script/register"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/qix-/node-error-ex"
  },
  "files": [
    "index.js"
  ],
  "devDependencies": {
    "coffee-script": "^1.9.3",
    "coveralls": "^2.11.2",
    "istanbul": "^0.3.17",
    "mocha": "^2.2.5",
    "should": "^7.0.1",
    "xo": "^0.7.1"
  },
  "readme": "# node-error-ex [![Travis-CI.org Build Status](https://img.shields.io/travis/Qix-/node-error-ex.svg?style=flat-square)](https://travis-ci.org/Qix-/node-error-ex) [![Coveralls.io Coverage Rating](https://img.shields.io/coveralls/Qix-/node-error-ex.svg?style=flat-square)](https://coveralls.io/r/Qix-/node-error-ex)\n> Easily subclass and customize new Error types\n\n## Examples\nTo include in your project:\n```javascript\nvar errorEx = require('error-ex');\n```\n\nTo create an error message type with a specific name (note, that `ErrorFn.name`\nwill not reflect this):\n```javascript\nvar JSONError = errorEx('JSONError');\n\nvar err = new JSONError('error');\nerr.name; //-> JSONError\nthrow err; //-> JSONError: error\n```\n\nTo add a stack line:\n```javascript\nvar JSONError = errorEx('JSONError', {fileName: errorEx.line('in %s')});\n\nvar err = new JSONError('error')\nerr.fileName = '/a/b/c/foo.json';\nthrow err; //-> (line 2)-> in /a/b/c/foo.json\n```\n\nTo append to the error message:\n```javascript\nvar JSONError = errorEx('JSONError', {fileName: errorEx.append('in %s')});\n\nvar err = new JSONError('error');\nerr.fileName = '/a/b/c/foo.json';\nthrow err; //-> JSONError: error in /a/b/c/foo.json\n```\n\n## API\n\n#### `errorEx([name], [properties])`\nCreates a new ErrorEx error type\n\n- `name`: the name of the new type (appears in the error message upon throw;\n  defaults to `Error.name`)\n- `properties`: if supplied, used as a key/value dictionary of properties to\n  use when building up the stack message. Keys are property names that are\n  looked up on the error message, and then passed to function values.\n\t- `line`: if specified and is a function, return value is added as a stack\n    entry (error-ex will indent for you). Passed the property value given\n    the key.\n  - `stack`: if specified and is a function, passed the value of the property\n    using the key, and the raw stack lines as a second argument. Takes no\n    return value (but the stack can be modified directly).\n  - `message`: if specified and is a function, return value is used as new\n    `.message` value upon get. Passed the property value of the property named\n    by key, and the existing message is passed as the second argument as an\n    array of lines (suitable for multi-line messages).\n\nReturns a constructor (Function) that can be used just like the regular Error\nconstructor.\n\n```javascript\nvar errorEx = require('error-ex');\n\nvar BasicError = errorEx();\n\nvar NamedError = errorEx('NamedError');\n\n// --\n\nvar AdvancedError = errorEx('AdvancedError', {\n\tfoo: {\n\t\tline: function (value, stack) {\n\t\t\tif (value) {\n\t\t\t\treturn 'bar ' + value;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n}\n\nvar err = new AdvancedError('hello, world');\nerr.foo = 'baz';\nthrow err;\n\n/*\n\tAdvancedError: hello, world\n\t    bar baz\n\t    at tryReadme() (readme.js:20:1)\n*/\n```\n\n#### `errorEx.line(str)`\nCreates a stack line using a delimiter\n\n> This is a helper function. It is to be used in lieu of writing a value object\n> for `properties` values.\n\n- `str`: The string to create\n  - Use the delimiter `%s` to specify where in the string the value should go\n\n```javascript\nvar errorEx = require('error-ex');\n\nvar FileError = errorEx('FileError', {fileName: errorEx.line('in %s')});\n\nvar err = new FileError('problem reading file');\nerr.fileName = '/a/b/c/d/foo.js';\nthrow err;\n\n/*\n\tFileError: problem reading file\n\t    in /a/b/c/d/foo.js\n\t    at tryReadme() (readme.js:7:1)\n*/\n```\n\n#### `errorEx.append(str)`\nAppends to the `error.message` string\n\n> This is a helper function. It is to be used in lieu of writing a value object\n> for `properties` values.\n\n- `str`: The string to append\n  - Use the delimiter `%s` to specify where in the string the value should go\n\n```javascript\nvar errorEx = require('error-ex');\n\nvar SyntaxError = errorEx('SyntaxError', {fileName: errorEx.append('in %s')});\n\nvar err = new SyntaxError('improper indentation');\nerr.fileName = '/a/b/c/d/foo.js';\nthrow err;\n\n/*\n\tSyntaxError: improper indentation in /a/b/c/d/foo.js\n\t    at tryReadme() (readme.js:7:1)\n*/\n```\n\n## License\nLicensed under the [MIT License](http://opensource.org/licenses/MIT).\nYou can find a copy of it in [LICENSE](LICENSE).\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/qix-/node-error-ex/issues"
  },
  "homepage": "https://github.com/qix-/node-error-ex",
  "_id": "error-ex@1.2.0",
  "dist": {
    "shasum": "dc8771f835685d692afadad82f18a992c828a5ec"
  },
  "_from": "error-ex@^1.2.0",
  "_resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.2.0.tgz"
}
