Skip to content

Commit 4834be3

Browse files
Trottruyadorno
authored andcommitted
lib: add comments to empty catch statements
PR-URL: #41831 Refs: https://eslint.org/docs/rules/no-empty Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 8a42a20 commit 4834be3

File tree

14 files changed

+59
-19
lines changed

14 files changed

+59
-19
lines changed

‎lib/events.js‎

Lines 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
constsep=`\nEmitted 'error' event${ctorInfo} at:\n`;
450452

451453
consterrStack=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.

‎lib/fs.js‎

Lines 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
constresolvedType=!err&&stat.isDirectory() ? 'dir' : 'file';

‎lib/internal/bootstrap/pre_execution.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ function patchProcessObject(expandArgv1){
101101
constpath=require('path');
102102
try{
103103
process.argv[1]=path.resolve(process.argv[1]);
104-
}catch{}
104+
}catch{
105+
// Continue regardless of error.
106+
}
105107
}
106108

107109
// TODO(joyeecheung): most of these should be deprecated and removed,

‎lib/internal/error_serdes.js‎

Lines 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'indescriptor&&typeofdescriptor.value!=='function'){
5456
deletedescriptor.get;
@@ -107,11 +109,15 @@ function serializeError(error){
107109
}
108110
}
109111
}
110-
}catch{}
112+
}catch{
113+
// Continue regardless of error.
114+
}
111115
try{
112116
constserialized=serialize(error);
113117
returnBuffer.concat([Buffer.from([kSerializedObject]),serialized]);
114-
}catch{}
118+
}catch{
119+
// Continue regardless of error.
120+
}
115121
returnBuffer.concat([Buffer.from([kInspectedError]),
116122
Buffer.from(inspect(error),'utf8')]);
117123
}

‎lib/internal/main/worker_thread.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,18 @@ function workerOnGlobalUncaughtException(error, fromPromise){
226226
if(!handlerThrew){
227227
process.emit('exit',process.exitCode);
228228
}
229-
}catch{}
229+
}catch{
230+
// Continue regardless of error.
231+
}
230232
}
231233

232234
letserialized;
233235
try{
234236
const{ serializeError }=require('internal/error_serdes');
235237
serialized=serializeError(error);
236-
}catch{}
238+
}catch{
239+
// Continue regardless of error.
240+
}
237241
debug(`[${threadId}] uncaught exception serialized = ${!!serialized}`);
238242
if(serialized)
239243
port.postMessage({

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,9 @@ Module._extensions['.js'] = function(module, filename){
11281128
letparentSource;
11291129
try{
11301130
parentSource=fs.readFileSync(parentPath,'utf8');
1131-
}catch{}
1131+
}catch{
1132+
// Continue regardless of error.
1133+
}
11321134
if(parentSource){
11331135
consterrLine=StringPrototypeSplit(
11341136
StringPrototypeSlice(err.stack,StringPrototypeIndexOf(

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

Lines 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
awaitthis.loader.load(childFileURL));
157-
}catch{}
157+
}catch{
158+
// Continue regardless of error.
159+
}
158160

159161
if(format==='commonjs'){
160162
constimportStatement=splitStack[1];

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,9 @@ function resolvePackageTargetString(
474474
try{
475475
newURL(target);
476476
isURL=true;
477-
}catch{}
477+
}catch{
478+
// Continue regardless of error.
479+
}
478480
if(!isURL){
479481
constexportTarget=pattern ?
480482
RegExpPrototypeSymbolReplace(patternRegEx,target,()=>subpath) :

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

Lines 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
letvalue;
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
letsource;
206208
try{
207209
source=readFileSync(filename,'utf8');
208-
}catch{}
210+
}catch{
211+
// Continue regardless of error.
212+
}
209213

210214
letexports,reexports;
211215
try{

‎lib/internal/policy/manifest.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ function canonicalizeSpecifier(specifier, base){
639639
returnresolve(specifier,base).href;
640640
}
641641
returnresolve(specifier).href;
642-
}catch{}
642+
}catch{
643+
// Continue regardless of error.
644+
}
643645
returnspecifier;
644646
}
645647

0 commit comments

Comments
(0)