Skip to content

Commit 22f6ac7

Browse files
committed
Add stack trace to unhandled error log message
This change sets the `fullMessage` of the `showAndLogExceptionWithTelemetry` to include the stack trace. This makes it possible to find the source of the error rather than only knowing that a specific error occurred. If the error does not have a stack trace (which should be rare) the message will be the same as before.
1 parent 4ee86c1 commit 22f6ac7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,13 +1164,16 @@ function addUnhandledRejectionListener() {
11641164
const message = redactableError(
11651165
asError(error),
11661166
)`Unhandled error: ${getErrorMessage(error)}`;
1167+
const stack = getErrorStack(error);
1168+
const fullMessage = stack
1169+
? `Unhandled error: ${stack}`
1170+
: message.fullMessage;
1171+
11671172
// Add a catch so that showAndLogExceptionWithTelemetry fails, we avoid
11681173
// triggering "unhandledRejection" and avoid an infinite loop
1169-
showAndLogExceptionWithTelemetry(
1170-
extLogger,
1171-
telemetryListener,
1172-
message,
1173-
).catch((telemetryError: unknown) => {
1174+
showAndLogExceptionWithTelemetry(extLogger, telemetryListener, message, {
1175+
fullMessage,
1176+
}).catch((telemetryError: unknown) => {
11741177
void extLogger.log(
11751178
`Failed to send error telemetry: ${getErrorMessage(telemetryError)}`,
11761179
);

0 commit comments

Comments
 (0)