提交 36e113e5 编写于 作者: M mmulet 提交者: Peng Lyu

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'
上级 02702327
...@@ -299,10 +299,12 @@ class LinkDetector implements editorCommon.IEditorContribution { ...@@ -299,10 +299,12 @@ class LinkDetector implements editorCommon.IEditorContribution {
return this.openerService.open(uri, { openToSide }); return this.openerService.open(uri, { openToSide });
}, err => { }, err => {
const messageOrError =
err instanceof Error ? (<Error>err).message : err;
// different error cases // 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())); 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.')); this.notificationService.warn(nls.localize('missing.url', 'Failed to open this link because its target is missing.'));
} else { } else {
onUnexpectedError(err); onUnexpectedError(err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册