Skip to content

Commit e27b9f1

Browse files
author
Akos Kitta
committed
💄 improved dev comments.
Signed-off-by: Akos Kitta <[email protected]>
1 parent c7f2f4f commit e27b9f1

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

arduino-ide-extension/src/node/core-client-provider.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl
137137
);
138138
}
139139

140-
// Final error codes are not yet defined by the CLI. Hence, we do string match in the error message.
140+
// Final error codes are not yet defined by the CLI. Hence, we do string matching in the message RPC status.
141141
private isRpcStatusError(
142142
error: unknown,
143143
assert: (message: string) => boolean
@@ -212,26 +212,23 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl
212212
if (error) {
213213
console.error(error.getMessage());
214214
errorStatus.push(error);
215-
// Cancel the init request. This will result in a cancel error.
215+
// Cancel the init request. No need to wait until the end of the event. The init has already failed.
216+
// Canceling the request will result in a cancel error, but we need to reject with the original error later.
216217
stream.cancel();
217218
}
218219
});
219220
stream.on('error', (error) => {
220-
// on any error during the init request, the request is canceled.
221-
// on cancel, the IDE2 ignores the cancel error and rejects with the original one.
221+
// On any error during the init request, the request is canceled.
222+
// On cancel, the IDE2 ignores the cancel error and rejects with the original one.
222223
reject(
223224
this.isCancelError(error) && errorStatus.length
224225
? errorStatus[0]
225226
: error
226227
);
227228
});
228-
stream.on('end', () => {
229-
if (errorStatus.length) {
230-
reject(errorStatus);
231-
} else {
232-
resolve();
233-
}
234-
});
229+
stream.on('end', () =>
230+
errorStatus.length ? reject(errorStatus) : resolve()
231+
);
235232
});
236233
}
237234

0 commit comments

Comments
 (0)