Skip to content

Commit fdee274

Browse files
authored
Log uncaught exceptions (#252)
1 parent 17fdd4d commit fdee274

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/app/standalone.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ const lsp = new LspConnection(createConnection(ProposedFeatures.all), {
6666
onExit,
6767
});
6868
lsp.listen();
69+
70+
process.on('unhandledRejection', (reason, _promise) => {
71+
getLogger().error(reason, 'Unhandled promise rejection');
72+
});
73+
74+
process.on('uncaughtException', (error, origin) => {
75+
getLogger().error(error, `Uncaught exception ${origin}`);
76+
});

src/telemetry/TelemetryService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ export class TelemetryService implements Closeable {
152152

153153
private registerErrorHandlers(telemetry: ScopedTelemetry): void {
154154
process.on('unhandledRejection', (reason, _promise) => {
155-
this.logger.error(reason, 'Unhandled promise rejection');
156-
157155
const location = reason instanceof Error ? extractLocationFromStack(reason.stack) : {};
158156
telemetry.count('process.promise.unhandled', 1, {
159157
attributes: {
@@ -166,8 +164,6 @@ export class TelemetryService implements Closeable {
166164
});
167165

168166
process.on('uncaughtException', (error, origin) => {
169-
this.logger.error(error, `Uncaught exception ${origin}`);
170-
171167
telemetry.count('process.exception.uncaught', 1, {
172168
attributes: {
173169
'error.type': error.name,

0 commit comments

Comments
 (0)