forked from public/fvtt-cthulhu-eternal
Initial import with skill sheet working
This commit is contained in:
23
node_modules/module-error/CHANGELOG.md
generated
vendored
Normal file
23
node_modules/module-error/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## [1.0.2] - 2022-02-19
|
||||
|
||||
### Fixed
|
||||
|
||||
- Align LICENSE format with standardized SPDX ([`915c436`](https://github.com/vweevers/module-error/commit/915c436)).
|
||||
|
||||
## [1.0.1] - 2021-10-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Add types ([`027e1ea`](https://github.com/vweevers/module-error/commit/027e1ea))
|
||||
|
||||
## [1.0.0] - 2021-10-22
|
||||
|
||||
:seedling: Initial release.
|
||||
|
||||
[1.0.2]: https://github.com/vweevers/module-error/releases/tag/v1.0.2
|
||||
|
||||
[1.0.1]: https://github.com/vweevers/module-error/releases/tag/v1.0.1
|
||||
|
||||
[1.0.0]: https://github.com/vweevers/module-error/releases/tag/v1.0.0
|
21
node_modules/module-error/LICENSE
generated
vendored
Normal file
21
node_modules/module-error/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Vincent Weevers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
89
node_modules/module-error/README.md
generated
vendored
Normal file
89
node_modules/module-error/README.md
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
# module-error
|
||||
|
||||
**Create errors with `code` and `cause` properties. Simple and extensible.**
|
||||
|
||||
[](https://www.npmjs.org/package/module-error)
|
||||
[](https://www.npmjs.org/package/module-error)
|
||||
[](https://github.com/vweevers/module-error/actions/workflows/test.yml)
|
||||
[](https://standardjs.com)
|
||||
[](https://common-changelog.org)
|
||||
|
||||
## Usage
|
||||
|
||||
Works like a regular `Error` constructor but adds an options argument (as [`proposal-error-cause`](https://github.com/tc39/proposal-error-cause) does).
|
||||
|
||||
```js
|
||||
const ModuleError = require('module-error')
|
||||
|
||||
throw new ModuleError('Message goes here', {
|
||||
code: 'EXAMPLE_NOT_FOUND'
|
||||
})
|
||||
```
|
||||
|
||||
The primary purpose of `ModuleError` is to define a `code` property on the error object following Node.js conventions. It should be set to an uppercase string that uniquely identifies a situation, prefixed with the name of your module (or a collection of modules) to prevent conflicts.
|
||||
|
||||
The output looks like this in Node.js (some stack frames omitted for brevity):
|
||||
|
||||
```
|
||||
ModuleError: Message goes here
|
||||
at Object.<anonymous> (/home/app/example.js:5:7)
|
||||
at node:internal/main/run_main_module:17:47 {
|
||||
code: 'EXAMPLE_NOT_FOUND'
|
||||
}
|
||||
```
|
||||
|
||||
The benefit of error codes is that messages can be changed without a semver-major release because your [semver](https://semver.org) contract will be on the codes. Codes can be reused across related modules while allowing individual modules to customize messages. I also prefer it over `instanceof MyError` logic because codes work cross-realm and when a tree of `node_modules` contains multiple versions of a module.
|
||||
|
||||
To wrap another error:
|
||||
|
||||
```js
|
||||
try {
|
||||
JSON.parse(await fs.readFile('state.json'))
|
||||
} catch (err) {
|
||||
throw new ModuleError('Could not load state', {
|
||||
code: 'EXAMPLE_INVALID_STATE',
|
||||
cause: err
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
If for convenience you want to create subclasses with prepared codes:
|
||||
|
||||
```js
|
||||
class NotFoundError extends ModuleError {
|
||||
constructor(message, options) {
|
||||
super(message, { ...options, code: 'EXAMPLE_NOT_FOUND' })
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then you can do:
|
||||
|
||||
```js
|
||||
throw new NotFoundError('Message goes here')
|
||||
```
|
||||
|
||||
Under Node.js the stack trace will be adjusted accordingly, to skip the frame containing your error constructor.
|
||||
|
||||
## API
|
||||
|
||||
### `ModuleError(message, [options])`
|
||||
|
||||
Constructor to create an error with the provided `message` string. Options:
|
||||
|
||||
- `code` (string): if provided, define a `code` property with this value.
|
||||
- `cause` (Error): if provided, define a `cause` property with this value. Unlike the spec of [`proposal-error-cause`](https://github.com/tc39/proposal-error-cause) the property is enumerable so that Node.js (v16 at the time of writing) will print it. Firefox prints it regardless, Chromium doesn't yet.
|
||||
- `expected`: if truthy, define a `expected` property with value `true`. This is useful for command line interfaces to differentiate unexpected errors from e.g. invalid user input. A pattern I like to follow is to print only an error message if `err.expected` is true and no `--verbose` flag was provided. Otherwise print the full stack.
|
||||
- `transient`: if truthy, define a `transient` property with value `true`. This communicates to users that the operation that caused the error may be retried. See also [`transient-error`](https://github.com/vweevers/transient-error) to mark existing errors as transient.
|
||||
|
||||
## Install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install module-error
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
18
node_modules/module-error/index.d.ts
generated
vendored
Normal file
18
node_modules/module-error/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
declare class ModuleError extends Error {
|
||||
/**
|
||||
* @param message Error message
|
||||
*/
|
||||
constructor(message: string, options?: {
|
||||
code?: string
|
||||
cause?: Error
|
||||
expected?: boolean
|
||||
transient?: boolean
|
||||
} | undefined)
|
||||
|
||||
code: string | undefined
|
||||
expected: boolean | undefined
|
||||
transient: boolean | undefined
|
||||
cause: Error | undefined
|
||||
}
|
||||
|
||||
export = ModuleError
|
22
node_modules/module-error/index.js
generated
vendored
Normal file
22
node_modules/module-error/index.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = class ModuleError extends Error {
|
||||
/**
|
||||
* @param {string} message Error message
|
||||
* @param {{ code?: string, cause?: Error, expected?: boolean, transient?: boolean }} [options]
|
||||
*/
|
||||
constructor (message, options) {
|
||||
super(message || '')
|
||||
|
||||
if (typeof options === 'object' && options !== null) {
|
||||
if (options.code) this.code = String(options.code)
|
||||
if (options.expected) this.expected = true
|
||||
if (options.transient) this.transient = true
|
||||
if (options.cause) this.cause = options.cause
|
||||
}
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor)
|
||||
}
|
||||
}
|
||||
}
|
36
node_modules/module-error/package.json
generated
vendored
Normal file
36
node_modules/module-error/package.json
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "module-error",
|
||||
"version": "1.0.2",
|
||||
"description": "Create errors with code and cause properties",
|
||||
"license": "MIT",
|
||||
"author": "Vincent Weevers",
|
||||
"scripts": {
|
||||
"test": "standard && tsc && hallmark && node test",
|
||||
"build": "tsc -d --emitDeclarationOnly --noEmit false"
|
||||
},
|
||||
"types": "./index.d.ts",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.6",
|
||||
"@voxpelli/tsconfig": "^3.0.0",
|
||||
"hallmark": "^4.0.0",
|
||||
"standard": "^16.0.4",
|
||||
"tape": "^5.3.1",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"keywords": [
|
||||
"cause",
|
||||
"code",
|
||||
"error"
|
||||
],
|
||||
"repository": "vweevers/module-error",
|
||||
"bugs": "https://github.com/vweevers/module-error/issues",
|
||||
"homepage": "https://github.com/vweevers/module-error",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user