From 36e113e5a63c7d9179db93e259d3667e1e84b0e8 Mon Sep 17 00:00:00 2001 From: mmulet Date: Mon, 12 Aug 2019 15:49:21 -0500 Subject: [PATCH] Fixed Issue 78731 (#78732) * Fixed Issue 78731 The error handler for OpenLinkOccurrence handled the case of 'invalid' or 'message', but the function returns an error of new Error('invalid') or new Error('missing') instead of 'invalid' or 'missing'. This causes the editor to throw an unhandled exception instead of a warning message. This fix checks for an err.message as well as err for 'invalid' or 'missing' --- src/vs/editor/contrib/links/links.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/links/links.ts b/src/vs/editor/contrib/links/links.ts index 53ea1177390..f9f19e5211c 100644 --- a/src/vs/editor/contrib/links/links.ts +++ b/src/vs/editor/contrib/links/links.ts @@ -299,10 +299,12 @@ class LinkDetector implements editorCommon.IEditorContribution { return this.openerService.open(uri, { openToSide }); }, err => { + const messageOrError = + err instanceof Error ? (err).message : err; // different error cases - if (err === 'invalid') { + if (messageOrError === 'invalid') { this.notificationService.warn(nls.localize('invalid.url', 'Failed to open this link because it is not well-formed: {0}', link.url!.toString())); - } else if (err === 'missing') { + } else if (messageOrError === 'missing') { this.notificationService.warn(nls.localize('missing.url', 'Failed to open this link because its target is missing.')); } else { onUnexpectedError(err); -- GitLab