mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
lib: add comments to empty catch statements
PR-URL: https://github.com/nodejs/node/pull/41831 Backport-PR-URL: https://github.com/nodejs/node/pull/42160 Refs: https://eslint.org/docs/rules/no-empty Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
330c1bc518
commit
acd8768802
14 files changed
+59
-19
No files matched your search
+6
-2
@@ -445,7 +445,9 @@ function enhanceStackTrace(err, own) {
|
||||
const { name } = this.constructor;
|
||||
if (name !== 'EventEmitter')
|
||||
ctorInfo = ` on ${name} instance`;
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
const sep = `\nEmitted 'error' event${ctorInfo} at:\n`;
|
||||
|
||||
const errStack = ArrayPrototypeSlice(
|
||||
@@ -493,7 +495,9 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
|
||||
value: FunctionPrototypeBind(enhanceStackTrace, this, er, capture),
|
||||
configurable: true
|
||||
});
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
|
||||
// Note: The comments on the `throw` lines are intentional, they show
|
||||
// up in Node's output if this results in an unhandled exception.
|
||||
|
||||
@@ -1600,7 +1600,9 @@ function symlink(target, path, type_, callback_) {
|
||||
// errors consistent between platforms if invalid path is
|
||||
// provided.
|
||||
absoluteTarget = pathModule.resolve(path, '..', target);
|
||||
} catch { }
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
if (absoluteTarget !== undefined) {
|
||||
stat(absoluteTarget, (err, stat) => {
|
||||
const resolvedType = !err && stat.isDirectory() ? 'dir' : 'file';
|
||||
|
||||
@@ -97,7 +97,9 @@ function patchProcessObject(expandArgv1) {
|
||||
const path = require('path');
|
||||
try {
|
||||
process.argv[1] = path.resolve(process.argv[1]);
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(joyeecheung): most of these should be deprecated and removed,
|
||||
|
||||
@@ -48,7 +48,9 @@ function TryGetAllProperties(object, target = object) {
|
||||
if (getter && key !== '__proto__') {
|
||||
try {
|
||||
descriptor.value = FunctionPrototypeCall(getter, target);
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
}
|
||||
if ('value' in descriptor && typeof descriptor.value !== 'function') {
|
||||
delete descriptor.get;
|
||||
@@ -107,11 +109,15 @@ function serializeError(error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
try {
|
||||
const serialized = serialize(error);
|
||||
return Buffer.concat([Buffer.from([kSerializedObject]), serialized]);
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
return Buffer.concat([Buffer.from([kInspectedError]),
|
||||
Buffer.from(inspect(error), 'utf8')]);
|
||||
}
|
||||
|
||||
@@ -224,14 +224,18 @@ function workerOnGlobalUncaughtException(error, fromPromise) {
|
||||
if (!handlerThrew) {
|
||||
process.emit('exit', process.exitCode);
|
||||
}
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
}
|
||||
|
||||
let serialized;
|
||||
try {
|
||||
const { serializeError } = require('internal/error_serdes');
|
||||
serialized = serializeError(error);
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
debug(`[${threadId}] uncaught exception serialized = ${!!serialized}`);
|
||||
if (serialized)
|
||||
port.postMessage({
|
||||
|
||||
@@ -1134,7 +1134,9 @@ Module._extensions['.js'] = function(module, filename) {
|
||||
let parentSource;
|
||||
try {
|
||||
parentSource = fs.readFileSync(parentPath, 'utf8');
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
if (parentSource) {
|
||||
const errLine = StringPrototypeSplit(
|
||||
StringPrototypeSlice(err.stack, StringPrototypeIndexOf(
|
||||
|
||||
@@ -154,7 +154,9 @@ class ModuleJob {
|
||||
// care about CommonJS for the purposes of this error message.
|
||||
({ format } =
|
||||
await this.loader.load(childFileURL));
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
|
||||
if (format === 'commonjs') {
|
||||
const importStatement = splitStack[1];
|
||||
|
||||
@@ -498,7 +498,9 @@ function resolvePackageTargetString(
|
||||
try {
|
||||
new URL(target);
|
||||
isURL = true;
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
if (!isURL) {
|
||||
const exportTarget = pattern ?
|
||||
RegExpPrototypeSymbolReplace(patternRegEx, target, () => subpath) :
|
||||
|
||||
@@ -180,7 +180,9 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
|
||||
let value;
|
||||
try {
|
||||
value = exports[exportName];
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
this.setExport(exportName, value);
|
||||
}
|
||||
this.setExport('default', exports);
|
||||
@@ -205,7 +207,9 @@ function cjsPreparseModuleExports(filename) {
|
||||
let source;
|
||||
try {
|
||||
source = readFileSync(filename, 'utf8');
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
|
||||
let exports, reexports;
|
||||
try {
|
||||
|
||||
@@ -639,7 +639,9 @@ function canonicalizeSpecifier(specifier, base) {
|
||||
return resolve(specifier, base).href;
|
||||
}
|
||||
return resolve(specifier).href;
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
return specifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,9 @@ function createOnGlobalUncaughtException() {
|
||||
null,
|
||||
er ?? {});
|
||||
}
|
||||
} catch {} // Ignore the exception. Diagnostic reporting is unavailable.
|
||||
} catch {
|
||||
// Ignore the exception. Diagnostic reporting is unavailable.
|
||||
}
|
||||
}
|
||||
|
||||
const type = fromPromise ? 'unhandledRejection' : 'uncaughtException';
|
||||
|
||||
@@ -61,7 +61,9 @@ function writeToFile(message) {
|
||||
process.on('exit', () => {
|
||||
try {
|
||||
fs.closeSync(fd);
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
});
|
||||
}
|
||||
fs.appendFile(fd, `${message}\n`, (err) => {
|
||||
|
||||
@@ -268,7 +268,9 @@ function getUserOptions(ctx, isCrossContext) {
|
||||
let stylized;
|
||||
try {
|
||||
stylized = `${ctx.stylize(value, flavour)}`;
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
|
||||
if (typeof stylized !== 'string') return value;
|
||||
// `stylized` is a string as it should be, which is safe to pass along.
|
||||
|
||||
+5
-1
@@ -445,6 +445,7 @@ function REPLServer(prompt,
|
||||
// to the parent of `process.cwd()`.
|
||||
parentURL = pathToFileURL(path.join(process.cwd(), 'repl')).href;
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
|
||||
// Remove all "await"s and attempt running the script
|
||||
@@ -485,6 +486,7 @@ function REPLServer(prompt,
|
||||
// to the parent of `process.cwd()`.
|
||||
parentURL = pathToFileURL(path.join(process.cwd(), 'repl')).href;
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
while (true) {
|
||||
try {
|
||||
@@ -1236,7 +1238,9 @@ REPLServer.prototype.complete = function() {
|
||||
function gracefulReaddir(...args) {
|
||||
try {
|
||||
return ReflectApply(fs.readdirSync, null, args);
|
||||
} catch {}
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
}
|
||||
|
||||
function completeFSFunctions(line) {
|
||||
|
||||
Reference in new issue
Block a user