GT2/GT2-iOS/node_modules/verror/package.json

87 lines
23 KiB
JSON

{
"_args": [
[
{
"raw": "verror@1.10.0",
"scope": null,
"escapedName": "verror",
"name": "verror",
"rawSpec": "1.10.0",
"spec": "1.10.0",
"type": "version"
},
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/jsprim"
]
],
"_from": "verror@1.10.0",
"_id": "verror@1.10.0",
"_inCache": true,
"_location": "/verror",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/verror-1.10.0.tgz_1493743247437_0.7535550429020077"
},
"_npmUser": {
"name": "dap",
"email": "dap@cs.brown.edu"
},
"_npmVersion": "1.4.9",
"_phantomChildren": {},
"_requested": {
"raw": "verror@1.10.0",
"scope": null,
"escapedName": "verror",
"name": "verror",
"rawSpec": "1.10.0",
"spec": "1.10.0",
"type": "version"
},
"_requiredBy": [
"/jsprim"
],
"_resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
"_shasum": "3a105ca17053af55d6e270c1f8288682e18da400",
"_shrinkwrap": null,
"_spec": "verror@1.10.0",
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/jsprim",
"bugs": {
"url": "https://github.com/davepacheco/node-verror/issues"
},
"dependencies": {
"assert-plus": "^1.0.0",
"core-util-is": "1.0.2",
"extsprintf": "^1.2.0"
},
"description": "richer JavaScript errors",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "3a105ca17053af55d6e270c1f8288682e18da400",
"tarball": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz"
},
"engines": [
"node >=0.6.0"
],
"homepage": "https://github.com/davepacheco/node-verror#readme",
"license": "MIT",
"main": "./lib/verror.js",
"maintainers": [
{
"name": "dap",
"email": "dap@cs.brown.edu"
}
],
"name": "verror",
"optionalDependencies": {},
"readme": "# verror: rich JavaScript errors\n\nThis module provides several classes in support of Joyent's [Best Practices for\nError Handling in Node.js](http://www.joyent.com/developers/node/design/errors).\nIf you find any of the behavior here confusing or surprising, check out that\ndocument first.\n\nThe error classes here support:\n\n* printf-style arguments for the message\n* chains of causes\n* properties to provide extra information about the error\n* creating your own subclasses that support all of these\n\nThe classes here are:\n\n* **VError**, for chaining errors while preserving each one's error message.\n This is useful in servers and command-line utilities when you want to\n propagate an error up a call stack, but allow various levels to add their own\n context. See examples below.\n* **WError**, for wrapping errors while hiding the lower-level messages from the\n top-level error. This is useful for API endpoints where you don't want to\n expose internal error messages, but you still want to preserve the error chain\n for logging and debugging.\n* **SError**, which is just like VError but interprets printf-style arguments\n more strictly.\n* **MultiError**, which is just an Error that encapsulates one or more other\n errors. (This is used for parallel operations that return several errors.)\n\n\n# Quick start\n\nFirst, install the package:\n\n npm install verror\n\nIf nothing else, you can use VError as a drop-in replacement for the built-in\nJavaScript Error class, with the addition of printf-style messages:\n\n```javascript\nvar err = new VError('missing file: \"%s\"', '/etc/passwd');\nconsole.log(err.message);\n```\n\nThis prints:\n\n missing file: \"/etc/passwd\"\n\nYou can also pass a `cause` argument, which is any other Error object:\n\n```javascript\nvar fs = require('fs');\nvar filename = '/nonexistent';\nfs.stat(filename, function (err1) {\n\tvar err2 = new VError(err1, 'stat \"%s\"', filename);\n\tconsole.error(err2.message);\n});\n```\n\nThis prints out:\n\n stat \"/nonexistent\": ENOENT, stat '/nonexistent'\n\nwhich resembles how Unix programs typically report errors:\n\n $ sort /nonexistent\n sort: open failed: /nonexistent: No such file or directory\n\nTo match the Unixy feel, when you print out the error, just prepend the\nprogram's name to the VError's `message`. Or just call\n[node-cmdutil.fail(your_verror)](https://github.com/joyent/node-cmdutil), which\ndoes this for you.\n\nYou can get the next-level Error using `err.cause()`:\n\n```javascript\nconsole.error(err2.cause().message);\n```\n\nprints:\n\n ENOENT, stat '/nonexistent'\n\nOf course, you can chain these as many times as you want, and it works with any\nkind of Error:\n\n```javascript\nvar err1 = new Error('No such file or directory');\nvar err2 = new VError(err1, 'failed to stat \"%s\"', '/junk');\nvar err3 = new VError(err2, 'request failed');\nconsole.error(err3.message);\n```\n\nThis prints:\n\n request failed: failed to stat \"/junk\": No such file or directory\n\nThe idea is that each layer in the stack annotates the error with a description\nof what it was doing. The end result is a message that explains what happened\nat each level.\n\nYou can also decorate Error objects with additional information so that callers\ncan not only handle each kind of error differently, but also construct their own\nerror messages (e.g., to localize them, format them, group them by type, and so\non). See the example below.\n\n\n# Deeper dive\n\nThe two main goals for VError are:\n\n* **Make it easy to construct clear, complete error messages intended for\n people.** Clear error messages greatly improve both user experience and\n debuggability, so we wanted to make it easy to build them. That's why the\n constructor takes printf-style arguments.\n* **Make it easy to construct objects with programmatically-accessible\n metadata** (which we call _informational properties_). Instead of just saying\n \"connection refused while connecting to 192.168.1.2:80\", you can add\n properties like `\"ip\": \"192.168.1.2\"` and `\"tcpPort\": 80`. This can be used\n for feeding into monitoring systems, analyzing large numbers of Errors (as\n from a log file), or localizing error messages.\n\nTo really make this useful, it also needs to be easy to compose Errors:\nhigher-level code should be able to augment the Errors reported by lower-level\ncode to provide a more complete description of what happened. Instead of saying\n\"connection refused\", you can say \"operation X failed: connection refused\".\nThat's why VError supports `causes`.\n\nIn order for all this to work, programmers need to know that it's generally safe\nto wrap lower-level Errors with higher-level ones. If you have existing code\nthat handles Errors produced by a library, you should be able to wrap those\nErrors with a VError to add information without breaking the error handling\ncode. There are two obvious ways that this could break such consumers:\n\n* The error's name might change. People typically use `name` to determine what\n kind of Error they've got. To ensure compatibility, you can create VErrors\n with custom names, but this approach isn't great because it prevents you from\n representing complex failures. For this reason, VError provides\n `findCauseByName`, which essentially asks: does this Error _or any of its\n causes_ have this specific type? If error handling code uses\n `findCauseByName`, then subsystems can construct very specific causal chains\n for debuggability and still let people handle simple cases easily. There's an\n example below.\n* The error's properties might change. People often hang additional properties\n off of Error objects. If we wrap an existing Error in a new Error, those\n properties would be lost unless we copied them. But there are a variety of\n both standard and non-standard Error properties that should _not_ be copied in\n this way: most obviously `name`, `message`, and `stack`, but also `fileName`,\n `lineNumber`, and a few others. Plus, it's useful for some Error subclasses\n to have their own private properties -- and there'd be no way to know whether\n these should be copied. For these reasons, VError first-classes these\n information properties. You have to provide them in the constructor, you can\n only fetch them with the `info()` function, and VError takes care of making\n sure properties from causes wind up in the `info()` output.\n\nLet's put this all together with an example from the node-fast RPC library.\nnode-fast implements a simple RPC protocol for Node programs. There's a server\nand client interface, and clients make RPC requests to servers. Let's say the\nserver fails with an UnauthorizedError with message \"user 'bob' is not\nauthorized\". The client wraps all server errors with a FastServerError. The\nclient also wraps all request errors with a FastRequestError that includes the\nname of the RPC call being made. The result of this failed RPC might look like\nthis:\n\n name: FastRequestError\n message: \"request failed: server error: user 'bob' is not authorized\"\n rpcMsgid: <unique identifier for this request>\n rpcMethod: GetObject\n cause:\n name: FastServerError\n message: \"server error: user 'bob' is not authorized\"\n cause:\n name: UnauthorizedError\n message: \"user 'bob' is not authorized\"\n rpcUser: \"bob\"\n\nWhen the caller uses `VError.info()`, the information properties are collapsed\nso that it looks like this:\n\n message: \"request failed: server error: user 'bob' is not authorized\"\n rpcMsgid: <unique identifier for this request>\n rpcMethod: GetObject\n rpcUser: \"bob\"\n\nTaking this apart:\n\n* The error's message is a complete description of the problem. The caller can\n report this directly to its caller, which can potentially make its way back to\n an end user (if appropriate). It can also be logged.\n* The caller can tell that the request failed on the server, rather than as a\n result of a client problem (e.g., failure to serialize the request), a\n transport problem (e.g., failure to connect to the server), or something else\n (e.g., a timeout). They do this using `findCauseByName('FastServerError')`\n rather than checking the `name` field directly.\n* If the caller logs this error, the logs can be analyzed to aggregate\n errors by cause, by RPC method name, by user, or whatever. Or the\n error can be correlated with other events for the same rpcMsgid.\n* It wasn't very hard for any part of the code to contribute to this Error.\n Each part of the stack has just a few lines to provide exactly what it knows,\n with very little boilerplate.\n\nIt's not expected that you'd use these complex forms all the time. Despite\nsupporting the complex case above, you can still just do:\n\n new VError(\"my service isn't working\");\n\nfor the simple cases.\n\n\n# Reference: VError, WError, SError\n\nVError, WError, and SError are convenient drop-in replacements for `Error` that\nsupport printf-style arguments, first-class causes, informational properties,\nand other useful features.\n\n\n## Constructors\n\nThe VError constructor has several forms:\n\n```javascript\n/*\n * This is the most general form. You can specify any supported options\n * (including \"cause\" and \"info\") this way.\n */\nnew VError(options, sprintf_args...)\n\n/*\n * This is a useful shorthand when the only option you need is \"cause\".\n */\nnew VError(cause, sprintf_args...)\n\n/*\n * This is a useful shorthand when you don't need any options at all.\n */\nnew VError(sprintf_args...)\n```\n\nAll of these forms construct a new VError that behaves just like the built-in\nJavaScript `Error` class, with some additional methods described below.\n\nIn the first form, `options` is a plain object with any of the following\noptional properties:\n\nOption name | Type | Meaning\n---------------- | ---------------- | -------\n`name` | string | Describes what kind of error this is. This is intended for programmatic use to distinguish between different kinds of errors. Note that in modern versions of Node.js, this name is ignored in the `stack` property value, but callers can still use the `name` property to get at it.\n`cause` | any Error object | Indicates that the new error was caused by `cause`. See `cause()` below. If unspecified, the cause will be `null`.\n`strict` | boolean | If true, then `null` and `undefined` values in `sprintf_args` are passed through to `sprintf()`. Otherwise, these are replaced with the strings `'null'`, and '`undefined`', respectively.\n`constructorOpt` | function | If specified, then the stack trace for this error ends at function `constructorOpt`. Functions called by `constructorOpt` will not show up in the stack. This is useful when this class is subclassed.\n`info` | object | Specifies arbitrary informational properties that are available through the `VError.info(err)` static class method. See that method for details.\n\nThe second form is equivalent to using the first form with the specified `cause`\nas the error's cause. This form is distinguished from the first form because\nthe first argument is an Error.\n\nThe third form is equivalent to using the first form with all default option\nvalues. This form is distinguished from the other forms because the first\nargument is not an object or an Error.\n\nThe `WError` constructor is used exactly the same way as the `VError`\nconstructor. The `SError` constructor is also used the same way as the\n`VError` constructor except that in all cases, the `strict` property is\noverriden to `true.\n\n\n## Public properties\n\n`VError`, `WError`, and `SError` all provide the same public properties as\nJavaScript's built-in Error objects.\n\nProperty name | Type | Meaning\n------------- | ------ | -------\n`name` | string | Programmatically-usable name of the error.\n`message` | string | Human-readable summary of the failure. Programmatically-accessible details are provided through `VError.info(err)` class method.\n`stack` | string | Human-readable stack trace where the Error was constructed.\n\nFor all of these classes, the printf-style arguments passed to the constructor\nare processed with `sprintf()` to form a message. For `WError`, this becomes\nthe complete `message` property. For `SError` and `VError`, this message is\nprepended to the message of the cause, if any (with a suitable separator), and\nthe result becomes the `message` property.\n\nThe `stack` property is managed entirely by the underlying JavaScript\nimplementation. It's generally implemented using a getter function because\nconstructing the human-readable stack trace is somewhat expensive.\n\n## Class methods\n\nThe following methods are defined on the `VError` class and as exported\nfunctions on the `verror` module. They're defined this way rather than using\nmethods on VError instances so that they can be used on Errors not created with\n`VError`.\n\n### `VError.cause(err)`\n\nThe `cause()` function returns the next Error in the cause chain for `err`, or\n`null` if there is no next error. See the `cause` argument to the constructor.\nErrors can have arbitrarily long cause chains. You can walk the `cause` chain\nby invoking `VError.cause(err)` on each subsequent return value. If `err` is\nnot a `VError`, the cause is `null`.\n\n### `VError.info(err)`\n\nReturns an object with all of the extra error information that's been associated\nwith this Error and all of its causes. These are the properties passed in using\nthe `info` option to the constructor. Properties not specified in the\nconstructor for this Error are implicitly inherited from this error's cause.\n\nThese properties are intended to provide programmatically-accessible metadata\nabout the error. For an error that indicates a failure to resolve a DNS name,\ninformational properties might include the DNS name to be resolved, or even the\nlist of resolvers used to resolve it. The values of these properties should\ngenerally be plain objects (i.e., consisting only of null, undefined, numbers,\nbooleans, strings, and objects and arrays containing only other plain objects).\n\n### `VError.fullStack(err)`\n\nReturns a string containing the full stack trace, with all nested errors recursively\nreported as `'caused by:' + err.stack`.\n\n### `VError.findCauseByName(err, name)`\n\nThe `findCauseByName()` function traverses the cause chain for `err`, looking\nfor an error whose `name` property matches the passed in `name` value. If no\nmatch is found, `null` is returned.\n\nIf all you want is to know _whether_ there's a cause (and you don't care what it\nis), you can use `VError.hasCauseWithName(err, name)`.\n\nIf a vanilla error or a non-VError error is passed in, then there is no cause\nchain to traverse. In this scenario, the function will check the `name`\nproperty of only `err`.\n\n### `VError.hasCauseWithName(err, name)`\n\nReturns true if and only if `VError.findCauseByName(err, name)` would return\na non-null value. This essentially determines whether `err` has any cause in\nits cause chain that has name `name`.\n\n### `VError.errorFromList(errors)`\n\nGiven an array of Error objects (possibly empty), return a single error\nrepresenting the whole collection of errors. If the list has:\n\n* 0 elements, returns `null`\n* 1 element, returns the sole error\n* more than 1 element, returns a MultiError referencing the whole list\n\nThis is useful for cases where an operation may produce any number of errors,\nand you ultimately want to implement the usual `callback(err)` pattern. You can\naccumulate the errors in an array and then invoke\n`callback(VError.errorFromList(errors))` when the operation is complete.\n\n\n### `VError.errorForEach(err, func)`\n\nConvenience function for iterating an error that may itself be a MultiError.\n\nIn all cases, `err` must be an Error. If `err` is a MultiError, then `func` is\ninvoked as `func(errorN)` for each of the underlying errors of the MultiError.\nIf `err` is any other kind of error, `func` is invoked once as `func(err)`. In\nall cases, `func` is invoked synchronously.\n\nThis is useful for cases where an operation may produce any number of warnings\nthat may be encapsulated with a MultiError -- but may not be.\n\nThis function does not iterate an error's cause chain.\n\n\n## Examples\n\nThe \"Demo\" section above covers several basic cases. Here's a more advanced\ncase:\n\n```javascript\nvar err1 = new VError('something bad happened');\n/* ... */\nvar err2 = new VError({\n 'name': 'ConnectionError',\n 'cause': err1,\n 'info': {\n 'errno': 'ECONNREFUSED',\n 'remote_ip': '127.0.0.1',\n 'port': 215\n }\n}, 'failed to connect to \"%s:%d\"', '127.0.0.1', 215);\n\nconsole.log(err2.message);\nconsole.log(err2.name);\nconsole.log(VError.info(err2));\nconsole.log(err2.stack);\n```\n\nThis outputs:\n\n failed to connect to \"127.0.0.1:215\": something bad happened\n ConnectionError\n { errno: 'ECONNREFUSED', remote_ip: '127.0.0.1', port: 215 }\n ConnectionError: failed to connect to \"127.0.0.1:215\": something bad happened\n at Object.<anonymous> (/home/dap/node-verror/examples/info.js:5:12)\n at Module._compile (module.js:456:26)\n at Object.Module._extensions..js (module.js:474:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:312:12)\n at Function.Module.runMain (module.js:497:10)\n at startup (node.js:119:16)\n at node.js:935:3\n\nInformation properties are inherited up the cause chain, with values at the top\nof the chain overriding same-named values lower in the chain. To continue that\nexample:\n\n```javascript\nvar err3 = new VError({\n 'name': 'RequestError',\n 'cause': err2,\n 'info': {\n 'errno': 'EBADREQUEST'\n }\n}, 'request failed');\n\nconsole.log(err3.message);\nconsole.log(err3.name);\nconsole.log(VError.info(err3));\nconsole.log(err3.stack);\n```\n\nThis outputs:\n\n request failed: failed to connect to \"127.0.0.1:215\": something bad happened\n RequestError\n { errno: 'EBADREQUEST', remote_ip: '127.0.0.1', port: 215 }\n RequestError: request failed: failed to connect to \"127.0.0.1:215\": something bad happened\n at Object.<anonymous> (/home/dap/node-verror/examples/info.js:20:12)\n at Module._compile (module.js:456:26)\n at Object.Module._extensions..js (module.js:474:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:312:12)\n at Function.Module.runMain (module.js:497:10)\n at startup (node.js:119:16)\n at node.js:935:3\n\nYou can also print the complete stack trace of combined `Error`s by using\n`VError.fullStack(err).`\n\n```javascript\nvar err1 = new VError('something bad happened');\n/* ... */\nvar err2 = new VError(err1, 'something really bad happened here');\n\nconsole.log(VError.fullStack(err2));\n```\n\nThis outputs:\n\n VError: something really bad happened here: something bad happened\n at Object.<anonymous> (/home/dap/node-verror/examples/fullStack.js:5:12)\n at Module._compile (module.js:409:26)\n at Object.Module._extensions..js (module.js:416:10)\n at Module.load (module.js:343:32)\n at Function.Module._load (module.js:300:12)\n at Function.Module.runMain (module.js:441:10)\n at startup (node.js:139:18)\n at node.js:968:3\n caused by: VError: something bad happened\n at Object.<anonymous> (/home/dap/node-verror/examples/fullStack.js:3:12)\n at Module._compile (module.js:409:26)\n at Object.Module._extensions..js (module.js:416:10)\n at Module.load (module.js:343:32)\n at Function.Module._load (module.js:300:12)\n at Function.Module.runMain (module.js:441:10)\n at startup (node.js:139:18)\n at node.js:968:3\n\n`VError.fullStack` is also safe to use on regular `Error`s, so feel free to use\nit whenever you need to extract the stack trace from an `Error`, regardless if\nit's a `VError` or not.\n\n# Reference: MultiError\n\nMultiError is an Error class that represents a group of Errors. This is used\nwhen you logically need to provide a single Error, but you want to preserve\ninformation about multiple underying Errors. A common case is when you execute\nseveral operations in parallel and some of them fail.\n\nMultiErrors are constructed as:\n\n```javascript\nnew MultiError(error_list)\n```\n\n`error_list` is an array of at least one `Error` object.\n\nThe cause of the MultiError is the first error provided. None of the other\n`VError` options are supported. The `message` for a MultiError consists the\n`message` from the first error, prepended with a message indicating that there\nwere other errors.\n\nFor example:\n\n```javascript\nerr = new MultiError([\n new Error('failed to resolve DNS name \"abc.example.com\"'),\n new Error('failed to resolve DNS name \"def.example.com\"'),\n]);\n\nconsole.error(err.message);\n```\n\noutputs:\n\n first of 2 errors: failed to resolve DNS name \"abc.example.com\"\n\nSee the convenience function `VError.errorFromList`, which is sometimes simpler\nto use than this constructor.\n\n## Public methods\n\n\n### `errors()`\n\nReturns an array of the errors used to construct this MultiError.\n\n\n# Contributing\n\nSee separate [contribution guidelines](CONTRIBUTING.md).\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git://github.com/davepacheco/node-verror.git"
},
"scripts": {
"test": "make test"
},
"version": "1.10.0"
}