fix: surface underlying cause in ExtensionError for telemetry (fixes #321638) (#321645)

Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com>
Co-authored-by: Michael Lively <12552271+Yoyokrazy@users.noreply.github.com>
This commit is contained in:
vs-code-engineering[bot]
2026-07-01 03:47:34 +00:00
committed by GitHub
parent 84bf6e2e10
commit dc92e72c75

View File

@@ -506,9 +506,16 @@ export class ExtensionError extends Error {
readonly extension: ExtensionIdentifier;
constructor(extensionIdentifier: ExtensionIdentifier, cause: Error, message?: string) {
super(`Error in extension ${ExtensionIdentifier.toKey(extensionIdentifier)}: ${message ?? cause.message}`, { cause });
const detail = message && cause?.message ? `${message}: ${cause.message}` : (message ?? cause?.message);
super(`Error in extension ${ExtensionIdentifier.toKey(extensionIdentifier)}: ${detail}`, { cause });
this.name = 'ExtensionError';
this.extension = extensionIdentifier;
// Adopt the underlying cause's stack so error telemetry buckets by the real
// failure site inside the extension instead of the generic event-dispatch
// frames. Extension attribution relies on `this.extension`, not this stack.
if (cause?.stack) {
this.stack = cause.stack;
}
}
}