Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit acd8768

Browse filesBrowse files
Trottdanielleadams
authored andcommitted
lib: add comments to empty catch statements
PR-URL: #41831 Backport-PR-URL: #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>
1 parent 330c1bc commit acd8768
Copy full SHA for acd8768

File tree

Expand file treeCollapse file tree

14 files changed

+59
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

14 files changed

+59
-19
lines changed
Open diff view settings
Collapse file

‎lib/events.js‎

Copy file name to clipboardExpand all lines: lib/events.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ function enhanceStackTrace(err, own) {
445445
const { name } = this.constructor;
446446
if (name !== 'EventEmitter')
447447
ctorInfo = ` on ${name} instance`;
448-
} catch {}
448+
} catch {
449+
// Continue regardless of error.
450+
}
449451
const sep = `\nEmitted 'error' event${ctorInfo} at:\n`;
450452

451453
const errStack = ArrayPrototypeSlice(
@@ -493,7 +495,9 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
493495
value: FunctionPrototypeBind(enhanceStackTrace, this, er, capture),
494496
configurable: true
495497
});
496-
} catch {}
498+
} catch {
499+
// Continue regardless of error.
500+
}
497501

498502
// Note: The comments on the `throw` lines are intentional, they show
499503
// up in Node's output if this results in an unhandled exception.
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,9 @@ function symlink(target, path, type_, callback_) {
16001600
// errors consistent between platforms if invalid path is
16011601
// provided.
16021602
absoluteTarget = pathModule.resolve(path, '..', target);
1603-
} catch { }
1603+
} catch {
1604+
// Continue regardless of error.
1605+
}
16041606
if (absoluteTarget !== undefined) {
16051607
stat(absoluteTarget, (err, stat) => {
16061608
const resolvedType = !err && stat.isDirectory() ? 'dir' : 'file';
Collapse file

‎lib/internal/bootstrap/pre_execution.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/pre_execution.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ function patchProcessObject(expandArgv1) {
9797
const path = require('path');
9898
try {
9999
process.argv[1] = path.resolve(process.argv[1]);
100-
} catch {}
100+
} catch {
101+
// Continue regardless of error.
102+
}
101103
}
102104

103105
// TODO(joyeecheung): most of these should be deprecated and removed,
Collapse file

‎lib/internal/error_serdes.js‎

Copy file name to clipboardExpand all lines: lib/internal/error_serdes.js
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function TryGetAllProperties(object, target = object) {
4848
if (getter && key !== '__proto__') {
4949
try {
5050
descriptor.value = FunctionPrototypeCall(getter, target);
51-
} catch {}
51+
} catch {
52+
// Continue regardless of error.
53+
}
5254
}
5355
if ('value' in descriptor && typeof descriptor.value !== 'function') {
5456
delete descriptor.get;
@@ -107,11 +109,15 @@ function serializeError(error) {
107109
}
108110
}
109111
}
110-
} catch {}
112+
} catch {
113+
// Continue regardless of error.
114+
}
111115
try {
112116
const serialized = serialize(error);
113117
return Buffer.concat([Buffer.from([kSerializedObject]), serialized]);
114-
} catch {}
118+
} catch {
119+
// Continue regardless of error.
120+
}
115121
return Buffer.concat([Buffer.from([kInspectedError]),
116122
Buffer.from(inspect(error), 'utf8')]);
117123
}
Collapse file

‎lib/internal/main/worker_thread.js‎

Copy file name to clipboardExpand all lines: lib/internal/main/worker_thread.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,18 @@ function workerOnGlobalUncaughtException(error, fromPromise) {
224224
if (!handlerThrew) {
225225
process.emit('exit', process.exitCode);
226226
}
227-
} catch {}
227+
} catch {
228+
// Continue regardless of error.
229+
}
228230
}
229231

230232
let serialized;
231233
try {
232234
const { serializeError } = require('internal/error_serdes');
233235
serialized = serializeError(error);
234-
} catch {}
236+
} catch {
237+
// Continue regardless of error.
238+
}
235239
debug(`[${threadId}] uncaught exception serialized = ${!!serialized}`);
236240
if (serialized)
237241
port.postMessage({
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,9 @@ Module._extensions['.js'] = function(module, filename) {
11341134
let parentSource;
11351135
try {
11361136
parentSource = fs.readFileSync(parentPath, 'utf8');
1137-
} catch {}
1137+
} catch {
1138+
// Continue regardless of error.
1139+
}
11381140
if (parentSource) {
11391141
const errLine = StringPrototypeSplit(
11401142
StringPrototypeSlice(err.stack, StringPrototypeIndexOf(
Collapse file

‎lib/internal/modules/esm/module_job.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/module_job.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ class ModuleJob {
154154
// care about CommonJS for the purposes of this error message.
155155
({ format } =
156156
await this.loader.load(childFileURL));
157-
} catch {}
157+
} catch {
158+
// Continue regardless of error.
159+
}
158160

159161
if (format === 'commonjs') {
160162
const importStatement = splitStack[1];
Collapse file

‎lib/internal/modules/esm/resolve.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/resolve.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ function resolvePackageTargetString(
498498
try {
499499
new URL(target);
500500
isURL = true;
501-
} catch {}
501+
} catch {
502+
// Continue regardless of error.
503+
}
502504
if (!isURL) {
503505
const exportTarget = pattern ?
504506
RegExpPrototypeSymbolReplace(patternRegEx, target, () => subpath) :
Collapse file

‎lib/internal/modules/esm/translators.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/translators.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
180180
let value;
181181
try {
182182
value = exports[exportName];
183-
} catch {}
183+
} catch {
184+
// Continue regardless of error.
185+
}
184186
this.setExport(exportName, value);
185187
}
186188
this.setExport('default', exports);
@@ -205,7 +207,9 @@ function cjsPreparseModuleExports(filename) {
205207
let source;
206208
try {
207209
source = readFileSync(filename, 'utf8');
208-
} catch {}
210+
} catch {
211+
// Continue regardless of error.
212+
}
209213

210214
let exports, reexports;
211215
try {
Collapse file

‎lib/internal/policy/manifest.js‎

Copy file name to clipboardExpand all lines: lib/internal/policy/manifest.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ function canonicalizeSpecifier(specifier, base) {
639639
return resolve(specifier, base).href;
640640
}
641641
return resolve(specifier).href;
642-
} catch {}
642+
} catch {
643+
// Continue regardless of error.
644+
}
643645
return specifier;
644646
}
645647

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.