{"_id":"tea-error","_rev":"6-96c614b6e14748be6e59a6ebfd02f3ec","name":"tea-error","description":"Custom error constructor factory.","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"tea-error","version":"0.1.0","description":"Custom error constructor factory.","author":{"name":"Jake Luer","email":"jake@qualiancy.com","url":"http://qualiancy.com"},"license":"MIT","keywords":[],"repository":{"type":"git","url":"git@github.com:qualiancy/tea-error.git"},"engines":{"node":"*"},"main":"./index","scripts":{"test":"make test"},"dependencies":{"tea-extend":"0.2.0"},"devDependencies":{"chai":"*","component":"*","mocha":"*","mocha-phantomjs":"*"},"_id":"tea-error@0.1.0","dist":{"shasum":"782e3e4045886d408f1cc9ca56ce20588309f10a","tarball":"https://registry.npmjs.org/tea-error/-/tea-error-0.1.0.tgz","integrity":"sha512-PzrVx6+M+jhvJcDVKAOx51BE8LiNZwzepw4HWstK4h2Q2t/81KYFMzarPPXwpHQ7PwRPRIHVR9/pIvMtUxwa+g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICPmYa1/Gv2D459B344pZDI+OgkPX4uKt2yKI+TA2VO+AiASGVRDxuR5Lh1eKfAIRz3+Jh9df4oLbLwN0jTMR1WCeg=="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"jakeluer","email":"jake@alogicalparadox.com"},"maintainers":[{"name":"jakeluer","email":"jake@alogicalparadox.com"}]},"0.2.0":{"name":"tea-error","version":"0.2.0","description":"Custom error constructor factory.","author":{"name":"Jake Luer","email":"jake@alogicalparadox.com","url":"http://alogicalparadox.com"},"license":"MIT","keywords":[],"repository":{"type":"git","url":"git+ssh://git@github.com/logicalparadox/tea-error.git"},"engines":{"node":"*"},"main":"./index","scripts":{"test":"mocha"},"dependencies":{"params":"^0.1.1"},"devDependencies":{"chai":"*","mocha":"*"},"gitHead":"10fbbd3466447358ac9ba040aca9f6bf02e0d50c","bugs":{"url":"https://github.com/logicalparadox/tea-error/issues"},"homepage":"https://github.com/logicalparadox/tea-error#readme","_id":"tea-error@0.2.0","_shasum":"9693861007e76d46369cdff34d38548852454021","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"jakeluer","email":"jake@alogicalparadox.com"},"maintainers":[{"name":"jakeluer","email":"jake@alogicalparadox.com"}],"dist":{"shasum":"9693861007e76d46369cdff34d38548852454021","tarball":"https://registry.npmjs.org/tea-error/-/tea-error-0.2.0.tgz","integrity":"sha512-3bB6i1/wQAIejnK5VcvNV881dqRJFVv4dcchjnZnHwEBFK4hpUe2C0GIC2/NThjD8O+8dw69NPrHqVDTMWfrdA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFDwVto2Z14IY+0sF0hhBMXTVe+2BurvkDmppc7b5ydwAiBrExR2D0VAXEZGykUZXCli1f3359t3omTIDijllqyBnw=="}]}}},"readme":"# tea-error [![Build Status](https://secure.travis-ci.org/logicalparadox/tea-error.png?branch=master)](https://travis-ci.org/logicalparadox/tea-error)\n\n> Custom error constructor factory.\n\n## Installation\n\n`tea-error` is available on [npm](http://npmjs.org).\n\n    $ npm install tea-error\n\n## Usage\n\n### error (name)\n\n* **@param** _{String}_ name \n* **@return** _{Function}_  custom error constructor\n\nThe primary export for this module is a factory\nthat will return a constructor for a custom error\nof the type/name that is specified.\n\n```js\nvar error = require('tea-error')\nvar TestError = error('TestError')\nvar err = new TestError('My error message.')\n\nthrow err\n```\n\nAn error created/thrown from the custom constructor\nobserves all of the expected Javascript behaviors of\n`Error`.\n\n##### instanceof\n\nThe constructed error is an instanceof an Error.\n\n```js\nvar err = new Error()\nvar myerr = new TestError()\n\nerr.should.be.instanceof(Error)\nmyerr.should.be.instanceof(Error)\nmyerr.should.be.isntanceof(TestError)\n```\n\n##### name\n\nThe `name` property is defined like other \"native\" errors.\n\n```js\nvar err = new ReferenceError()\nvar myerr = new TestError()\n\nerr.should.have.property('name', 'ReferenceError')\nmyerr.should.have.property('name', 'TestError')\n```\n\n##### message\n\nThe `message` property is defined like all error and specified\nas the first argument during construction.\n\n```js\nvar err = new Error('Javascript error occurred')\nvar myerr = new TestError('Test error occurred')\n\nerr.should.have.property('message', 'Javascript error occurred')\nmyerr.should.have.property('message', 'Test Error occurred')\n```\n\n##### stack\n\nIf the environment provides the ability to capture a stack trace,\nit will be provided as the `stack` property. Please view your environments\ndocumentation to see if this is supported.\n\n```js\nvar err = new Error()\nvar myerr = new TestError()\n\nif (Error.captureStackTrace) {\n  err.should.have.property('stack')\n  myerr.should.have.property('stack')\n}\n```\n\n#### Construction\n\n* **@param** _{String}_ message \n* **@param** _{Object}_ properties \n* **@param** _{Callee}_ start stack function for captureStackTrace\n\nOnce the new constructor for an error has been created\nit can be used to construct errors just as normal javascript\nerrors.\n\n```js\nvar TestError = require('tea-errors')('TestError')\nvar err = new TestError('that did not work right')\n\nthrow err\n```\n\nThere are a number of additional arguments that can be\nspecified upon construction to provide further insight\ninto the error created.\n\n##### properties\n\nThe second argument during construction can be an object\nof properties that will be merged onto the newly created error.\n\n```js\nvar err = new TestError('expected field value', { fields: [ 'username' ] })\n\nerr.should.have.property('fields')\n  .an('array')\n  .that.deep.equals([ 'username' ])\n```\n\nNote that if the `name`, `message`, and `stack` properties are defined\nin this custom properties object, they will be ignored as those keys\nare reserved.\n\n##### start stack function\n\nThe start stack function is used by `Error.captureStackTrace`\nto indicate where the environment should start the visible\nstack trace. Modifying this value might be useful in situations\nwhere the internals of the module issuing the error are irrelevant\nto what occured. The most obvious example is providing feedback\nfor an api method.\n\n```js\n// api.js\nvar ApiError = require('tea-error')('ApiError')\n\nexports.use = function (fn) {\n  if ('function' !== typeof fn) {\n    throw new ApiError('API .use only accepts functions', null, arguments.callee);\n  }\n\n  // etc.\n}\n\n// user.js\nvar api = require('./api.js)\napi.use('a string?')\n```\n\nIn this scenario the first line of the error stack will reference\n`user.js-Ln:2` as opposed to `api.js-Ln:5`. See the `stack` example\nfor a demonstration.\n\n\n### .toJSON ()\n\n* **@param** _{Boolean}_ include stack\n* **@return** _{Object}_  JSON\n* **@alias** serialize\n\nConvert this error into a serialized JSON object.\n\n```js\nvar err = new TestError('some message', { hello: 'universe' })\nvar json = err.toJSON();\n\njson.should.deep.equal({\n  name: 'TestError',\n  message: 'some message',\n  hello: 'universe',\n  stack: '...'\n});\n```\n\nIf this method is called as `err.toJSON(false)` the\n`stack` property will not be included.\n\n\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 Jake Luer <jake@qualiancy.com> (http://qualiancy.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","maintainers":[{"name":"jakeluer","email":"jake@alogicalparadox.com"}],"time":{"modified":"2022-06-27T04:19:41.839Z","created":"2012-12-09T05:35:08.104Z","0.1.0":"2012-12-09T05:35:09.396Z","0.2.0":"2015-07-21T16:27:44.895Z"},"author":{"name":"Jake Luer","email":"jake@alogicalparadox.com","url":"http://alogicalparadox.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/logicalparadox/tea-error.git"},"homepage":"https://github.com/logicalparadox/tea-error#readme","keywords":[],"bugs":{"url":"https://github.com/logicalparadox/tea-error/issues"},"license":"MIT","readmeFilename":"README.md"}