Skip to content

Commit

Permalink
Error messages with links in url verification
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Feb 13, 2023
1 parent 36447ba commit e4313e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
36 changes: 19 additions & 17 deletions src/kernels/jupyter/serverSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
IQuickPickParameters,
InputFlowAction
} from '../../platform/common/utils/multiStepInput';
import { noop } from '../../platform/common/utils/misc';
import { capturePerfTelemetry, sendTelemetryEvent } from '../../telemetry';
import { Telemetry } from '../../telemetry';
import {
Expand Down Expand Up @@ -106,15 +105,15 @@ export async function validateSelectJupyterURI(
return DataScience.jupyterSelfCertExpiredErrorMessageOnly;
}
} else {
// Notify the user of web extension specific connection help
if (isWebExtension) {
applicationShell
.showErrorMessage(DataScience.remoteJupyterConnectionFailedWebExtension)
.then(noop, noop);
}

// Return the general connection error to show in the validation box
return DataScience.remoteJupyterConnectionFailedWithoutServerWithError(err.message || err.toString);
// Replace any Urls in the error message with markdown link.
const urlRegex = /(https?:\/\/[^\s]+)/g;
const errorMessage = (err.message || err.toString()).replace(urlRegex, (url: string) => `[${url}](${url})`);
return (
isWebExtension || true
? DataScience.remoteJupyterConnectionFailedWithoutServerWithErrorWeb
: DataScience.remoteJupyterConnectionFailedWithoutServerWithError
)(errorMessage);
}
}
}
Expand Down Expand Up @@ -664,15 +663,18 @@ class JupyterServerSelector_Insiders implements IJupyterServerSelector {
return DataScience.jupyterSelfCertExpiredErrorMessageOnly;
}
} else {
// Notify the user of web extension specific connection help
if (this.isWebExtension) {
this.applicationShell
.showErrorMessage(DataScience.remoteJupyterConnectionFailedWebExtension)
.then(noop, noop);
}

// Return the general connection error to show in the validation box
return DataScience.remoteJupyterConnectionFailedWithoutServerWithError(err.message || err.toString);
// Replace any Urls in the error message with markdown link.
const urlRegex = /(https?:\/\/[^\s]+)/g;
const errorMessage = (err.message || err.toString()).replace(
urlRegex,
(url: string) => `[${url}](${url})`
);
return (
this.isWebExtension || true
? DataScience.remoteJupyterConnectionFailedWithoutServerWithErrorWeb
: DataScience.remoteJupyterConnectionFailedWithoutServerWithError
)(errorMessage);
}
}
};
Expand Down
5 changes: 1 addition & 4 deletions src/platform/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,9 @@ export namespace DataScience {
l10n.t('Connection failure. Verify the server is running and reachable. ({0}).', errorMessage);
export const remoteJupyterConnectionFailedWithoutServerWithErrorWeb = (errorMessage: string) =>
l10n.t(
'Connection failure. Verify the server is running and reachable from a browser. ({0}). When connecting from vscode.dev Jupyter servers must be started with specific options to connect. See [here](https://aka.ms/vscjremoteweb) for more information.',
'Connection failure. Verify the server is running and reachable from a browser. ({0}). \nWhen connecting from vscode.dev Jupyter servers must be started with specific options to connect. \nClick [here](https://aka.ms/vscjremoteweb) for more information.',
errorMessage
);
export const remoteJupyterConnectionFailedWebExtension = l10n.t(
'When connecting from vscode.dev Jupyter servers must be started with specific options to connect. See [here](https://aka.ms/vscjremoteweb) for more information.'
);
export const removeRemoteJupyterConnectionButtonText = l10n.t('Forget Connection');
export const jupyterNotebookRemoteConnectFailedWeb = (hostName: string) =>
l10n.t(
Expand Down

0 comments on commit e4313e5

Please sign in to comment.