mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #6250 from overleaf/jpa-o-error-drop-poly-filling
[o-error] drop poly filling GitOrigin-RevId: 81bad387b374ce94597d9a34f1dcb0af21c98ad6
This commit is contained in:
parent
1b954fa720
commit
b3d4bd397f
5 changed files with 1038 additions and 3849 deletions
1
libraries/o-error/.gitignore
vendored
1
libraries/o-error/.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
dist
|
||||
.nyc_output
|
||||
coverage
|
||||
node_modules/
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"presets": [
|
||||
["@babel/env", {
|
||||
"targets": ["last 1 year", "ie 11", "firefox esr"],
|
||||
"useBuiltIns": "usage",
|
||||
"corejs": { "version": 3 }
|
||||
}]
|
||||
]
|
||||
}
|
83
libraries/o-error/index.d.ts
vendored
Normal file
83
libraries/o-error/index.d.ts
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
export = OError;
|
||||
/**
|
||||
* Light-weight helpers for handling JavaScript Errors in node.js and the
|
||||
* browser.
|
||||
*/
|
||||
declare class OError extends Error {
|
||||
/**
|
||||
* @param {string} message as for built-in Error
|
||||
* @param {Object} [info] extra data to attach to the error
|
||||
* @param {Error} [cause] the internal error that caused this error
|
||||
*/
|
||||
constructor(message: string, info?: any, cause?: Error);
|
||||
info: any;
|
||||
cause: Error;
|
||||
/** @private @type {Array<TaggedError> | undefined} */
|
||||
private _oErrorTags;
|
||||
/**
|
||||
* Set the extra info object for this error.
|
||||
*
|
||||
* @param {Object} info extra data to attach to the error
|
||||
* @return {this}
|
||||
*/
|
||||
withInfo(info: any): OError;
|
||||
/**
|
||||
* Wrap the given error, which caused this error.
|
||||
*
|
||||
* @param {Error} cause the internal error that caused this error
|
||||
* @return {this}
|
||||
*/
|
||||
withCause(cause: Error): OError;
|
||||
}
|
||||
declare namespace OError {
|
||||
/**
|
||||
* Tag debugging information onto any error (whether an OError or not) and
|
||||
* return it.
|
||||
*
|
||||
* @example <caption>An error in a callback</caption>
|
||||
* function findUser(name, callback) {
|
||||
* fs.readFile('/etc/passwd', (err, data) => {
|
||||
* if (err) return callback(OError.tag(err, 'failed to read passwd'))
|
||||
* // ...
|
||||
* })
|
||||
* }
|
||||
*
|
||||
* @example <caption>A possible error in a callback</caption>
|
||||
* function cleanup(callback) {
|
||||
* fs.unlink('/tmp/scratch', (err) => callback(err && OError.tag(err)))
|
||||
* }
|
||||
*
|
||||
* @example <caption>An error with async/await</caption>
|
||||
* async function cleanup() {
|
||||
* try {
|
||||
* await fs.promises.unlink('/tmp/scratch')
|
||||
* } catch (err) {
|
||||
* throw OError.tag(err, 'failed to remove scratch file')
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param {Error} error the error to tag
|
||||
* @param {string} [message] message with which to tag `error`
|
||||
* @param {Object} [info] extra data with wich to tag `error`
|
||||
* @return {Error} the modified `error` argument
|
||||
*/
|
||||
export function tag(error: Error, message?: string, info?: any): Error;
|
||||
/**
|
||||
* The merged info from any `tag`s and causes on the given error.
|
||||
*
|
||||
* If an info property is repeated, the last one wins.
|
||||
*
|
||||
* @param {Error | null | undefined} error any error (may or may not be an `OError`)
|
||||
* @return {Object}
|
||||
*/
|
||||
export function getFullInfo(error: Error): any;
|
||||
/**
|
||||
* Return the `stack` property from `error`, including the `stack`s for any
|
||||
* tagged errors added with `OError.tag` and for any `cause`s.
|
||||
*
|
||||
* @param {Error | null | undefined} error any error (may or may not be an `OError`)
|
||||
* @return {string}
|
||||
*/
|
||||
export function getFullStack(error: Error): string;
|
||||
export const maxTags: Number;
|
||||
}
|
4756
libraries/o-error/package-lock.json
generated
4756
libraries/o-error/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@overleaf/o-error",
|
||||
"version": "3.3.1",
|
||||
"version": "3.4.0",
|
||||
"description": "Light-weight helpers for handling JavaScript Errors in node.js and the browser. Helps with long stack traces, Error subclasses, wrapping internal errors (causes), and attaching extra data to errors for logging.",
|
||||
"keywords": [
|
||||
"browser",
|
||||
|
@ -12,18 +12,15 @@
|
|||
"cause",
|
||||
"verror"
|
||||
],
|
||||
"main": "dist/index.js",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"dist/index.js",
|
||||
"dist/index.d.ts"
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rm -rf dist",
|
||||
"build": "npm run --silent clean && npm run --silent typecheck && npm run --silent test && npm run --silent build:compile && npm run --silent declaration:build && npm run --silent update-readme",
|
||||
"build:compile": "babel index.js --out-dir dist",
|
||||
"declaration:build": "rm -f dist/index.d.ts && tsc --allowJs --declaration --emitDeclarationOnly --outDir dist --moduleResolution node --target ES6 index.js",
|
||||
"declaration:check": "git diff --exit-code -- dist/index.d.ts",
|
||||
"build": "npm run --silent typecheck && npm run --silent test && npm run --silent declaration:build && npm run --silent update-readme",
|
||||
"declaration:build": "rm -f index.d.ts && tsc --allowJs --declaration --emitDeclarationOnly --moduleResolution node --target ES6 index.js",
|
||||
"declaration:check": "git diff --exit-code -- index.d.ts",
|
||||
"lint": "../../node_modules/.bin/eslint --max-warnings 0 --format unix .",
|
||||
"lint:fix": "../../node_modules/.bin/eslint --fix .",
|
||||
"prepublishOnly": "npm run --silent declaration:build && npm run --silent declaration:check",
|
||||
|
@ -39,19 +36,14 @@
|
|||
"license": "MIT",
|
||||
"repository": "github:overleaf/o-error",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.10",
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/preset-env": "^7.12.11",
|
||||
"@types/chai": "^4.2.12",
|
||||
"@types/node": "^13.13.2",
|
||||
"chai": "^3.3.0",
|
||||
"jsdoc-to-markdown": "^5.0.3",
|
||||
"@types/chai": "^4.3.0",
|
||||
"@types/node": "^14.18.1",
|
||||
"chai": "^4.3.4",
|
||||
"jsdoc-to-markdown": "^7.1.0",
|
||||
"markdown-toc": "^1.2.0",
|
||||
"mocha": "^7.1.1",
|
||||
"nyc": "^15.0.1",
|
||||
"typescript": "^3.8.3"
|
||||
"mocha": "^9.1.3",
|
||||
"nyc": "^15.1.0",
|
||||
"typescript": "^4.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.8.3"
|
||||
}
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue