Skip to content

Fix uncaught errors reported by telemetry #1621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
{
"view": "ObjectScriptExplorer",
"contents": "Connect a local workspace folder to an [InterSystems server](https://docs.intersystems.com/components/csp/docbook/DocBook.UI.Page.cls?KEY=GVSCO_clientflow) if you want to export or import ObjectScript code.\n[Choose Server and Namespace](command:vscode-objectscript.connectFolderToServerNamespace)",
"when": "vscode-objectscript.explorerRootCount == 0"
"when": "vscode-objectscript.explorerRootCount == 0 && workspaceFolderCount != 0"
},
{
"view": "ObjectScriptProjectsExplorer",
Expand Down
19 changes: 12 additions & 7 deletions src/commands/connectFolderToServerNamespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ interface ConnSettings {
}

export async function connectFolderToServerNamespace(): Promise<void> {
if (!vscode.workspace.workspaceFolders?.length) {
vscode.window.showErrorMessage("No folders in the workspace.", "Dismiss");
return;
}
const serverManagerApi = await getServerManagerApi();
if (!serverManagerApi) {
vscode.window.showErrorMessage(
"Connecting a folder to a server namespace requires the [InterSystems Server Manager extension](https://marketplace.visualstudio.com/items?itemName=intersystems-community.servermanager) to be installed and enabled."
"Connecting a folder to a server namespace requires the [InterSystems Server Manager extension](https://marketplace.visualstudio.com/items?itemName=intersystems-community.servermanager) to be installed and enabled.",
"Dismiss"
);
return;
}
// Which folder?
const allFolders = vscode.workspace.workspaceFolders;
const items: vscode.QuickPickItem[] = allFolders
const items: vscode.QuickPickItem[] = vscode.workspace.workspaceFolders
.filter((folder) => notIsfs(folder.uri))
.map((folder) => {
const config = vscode.workspace.getConfiguration("objectscript", folder);
Expand All @@ -31,14 +35,14 @@ export async function connectFolderToServerNamespace(): Promise<void> {
};
});
if (!items.length) {
vscode.window.showErrorMessage("No local folders in the workspace.");
vscode.window.showErrorMessage("No local folders in the workspace.", "Dismiss");
return;
}
const pick =
items.length === 1 && !items[0].detail
? items[0]
: await vscode.window.showQuickPick(items, { title: "Pick a folder" });
const folder = allFolders.find((el) => el.name === pick.label);
const folder = vscode.workspace.workspaceFolders.find((el) => el.name === pick.label);
// Get user's choice of server
const options: vscode.QuickPickOptions = {};
const serverName: string = await serverManagerApi.pickServer(undefined, options);
Expand All @@ -60,7 +64,8 @@ export async function connectFolderToServerNamespace(): Promise<void> {
.catch((reason) => {
// Notify user about serverInfo failure
vscode.window.showErrorMessage(
reason.message || `Failed to fetch namespace list from server at ${connDisplayString}`
reason.message || `Failed to fetch namespace list from server at ${connDisplayString}`,
"Dismiss"
);
return undefined;
});
Expand All @@ -73,7 +78,7 @@ export async function connectFolderToServerNamespace(): Promise<void> {
}
// Handle serverInfo having returned no namespaces
if (!allNamespaces.length) {
vscode.window.showErrorMessage(`No namespace list returned by server at ${connDisplayString}`);
vscode.window.showErrorMessage(`No namespace list returned by server at ${connDisplayString}`, "Dismiss");
return;
}
// Get user's choice of namespace
Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export function uriOfWorkspaceFolder(workspaceFolder: string = currentWorkspaceF
return (
vscode.workspace.workspaceFolders.find((el): boolean => el.name.toLowerCase() === workspaceFolder.toLowerCase()) ||
vscode.workspace.workspaceFolders.find((el): boolean => el.uri.authority == workspaceFolder)
).uri;
)?.uri;
}

export function onlyUnique(value: { name: string }, index: number, self: { name: string }[]): boolean {
Expand Down Expand Up @@ -655,7 +655,7 @@ export async function addWsServerRootFolderData(wsFolders: readonly vscode.Works
* is required but not supported by the server and `err` was passed.
*/
export function redirectDotvscodeRoot(uri: vscode.Uri, err?: vscode.FileSystemError): vscode.Uri {
if (notIsfs(uri)) return;
if (notIsfs(uri)) return uri;
const dotMatch = uri.path.match(/^(.*)\/\.vscode(\/.*)?$/);
if (dotMatch) {
const dotvscodeRoot = uri.with({ path: dotMatch[1] || "/" });
Expand Down