tsoa
This commit is contained in:
10
node_modules/@hapi/bounce/LICENSE.md
generated
vendored
Executable file
10
node_modules/@hapi/bounce/LICENSE.md
generated
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
Copyright (c) 2017-2022, Project contributors
|
||||
Copyright (c) 2017-2020, Sideway Inc
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
17
node_modules/@hapi/bounce/README.md
generated
vendored
Executable file
17
node_modules/@hapi/bounce/README.md
generated
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
|
||||
|
||||
# @hapi/bounce
|
||||
|
||||
#### Selective error catching and rewrite rules.
|
||||
|
||||
**bounce** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) – they work even better together.
|
||||
|
||||
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://hapi.dev/family/bounce/)
|
||||
- [Versions status](https://hapi.dev/resources/status/#bounce) (builds, dependencies, node versions, licenses, eol)
|
||||
- [Changelog](https://hapi.dev/family/bounce/changelog/)
|
||||
- [Project policies](https://hapi.dev/policies/)
|
||||
- [Free and commercial support options](https://hapi.dev/support/)
|
||||
148
node_modules/@hapi/bounce/lib/index.js
generated
vendored
Executable file
148
node_modules/@hapi/bounce/lib/index.js
generated
vendored
Executable file
@@ -0,0 +1,148 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('assert');
|
||||
|
||||
const Boom = require('@hapi/boom');
|
||||
const Hoek = require('@hapi/hoek');
|
||||
|
||||
|
||||
const internals = {
|
||||
system: [
|
||||
|
||||
// JavaScript
|
||||
|
||||
EvalError,
|
||||
RangeError,
|
||||
ReferenceError,
|
||||
SyntaxError,
|
||||
TypeError,
|
||||
URIError,
|
||||
|
||||
// Node
|
||||
|
||||
Assert.AssertionError,
|
||||
|
||||
// Hoek
|
||||
|
||||
Hoek.AssertError
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
exports.rethrow = function (err, types, options = {}) {
|
||||
|
||||
return internals.catch(err, types, options, true);
|
||||
};
|
||||
|
||||
|
||||
exports.ignore = function (err, types, options = {}) {
|
||||
|
||||
return internals.catch(err, types, options, false);
|
||||
};
|
||||
|
||||
|
||||
internals.catch = function (err, types, options, match) {
|
||||
|
||||
if (internals.match(err, types) !== match) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Error replacement
|
||||
|
||||
if (options.override) {
|
||||
err = options.override;
|
||||
}
|
||||
|
||||
// Error decorations
|
||||
|
||||
if (options.decorate) {
|
||||
Object.assign(err, options.decorate);
|
||||
}
|
||||
|
||||
if (options.return) {
|
||||
return err;
|
||||
}
|
||||
|
||||
throw err;
|
||||
};
|
||||
|
||||
|
||||
exports.background = async function (operation, action = 'rethrow', types = 'system', options = {}) {
|
||||
|
||||
try {
|
||||
if (typeof operation === 'function') {
|
||||
await operation();
|
||||
}
|
||||
else {
|
||||
await operation;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
return exports[action](err, types, options);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.isBoom = function (err) {
|
||||
|
||||
return Boom.isBoom(err);
|
||||
};
|
||||
|
||||
|
||||
exports.isError = function (err) {
|
||||
|
||||
return err instanceof Error;
|
||||
};
|
||||
|
||||
|
||||
exports.isSystem = function (err) {
|
||||
|
||||
if (!err) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (err.isBoom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const system of internals.system) {
|
||||
if (err instanceof system) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
internals.rules = {
|
||||
system: exports.isSystem,
|
||||
boom: exports.isBoom
|
||||
};
|
||||
|
||||
|
||||
internals.match = function (err, types) {
|
||||
|
||||
if (!types) {
|
||||
return true;
|
||||
}
|
||||
|
||||
types = Array.isArray(types) ? types : [types];
|
||||
for (const type of types) {
|
||||
if (typeof type === 'string') {
|
||||
if (internals.rules[type](err)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (typeof type === 'object') {
|
||||
if (Hoek.contain(err, type, { deep: true, part: true })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (err instanceof type) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
33
node_modules/@hapi/bounce/package.json
generated
vendored
Normal file
33
node_modules/@hapi/bounce/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@hapi/bounce",
|
||||
"description": "Selective error catching and rewrite rules",
|
||||
"version": "3.0.2",
|
||||
"repository": "git://github.com/hapijs/bounce",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"keywords": [
|
||||
"error",
|
||||
"catch"
|
||||
],
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"plugin:@hapi/module"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@hapi/boom": "^10.0.1",
|
||||
"@hapi/hoek": "^11.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hapi/code": "^9.0.0",
|
||||
"@hapi/eslint-plugin": "^6.0.0",
|
||||
"@hapi/lab": "^25.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L",
|
||||
"test-cov-html": "lab -a @hapi/code -r html -o coverage.html -L"
|
||||
},
|
||||
"license": "BSD-3-Clause"
|
||||
}
|
||||
Reference in New Issue
Block a user