diff --git a/packages/zowe-explorer/l10n/bundle.l10n.json b/packages/zowe-explorer/l10n/bundle.l10n.json index ecb3e216dc..987ad22afe 100644 --- a/packages/zowe-explorer/l10n/bundle.l10n.json +++ b/packages/zowe-explorer/l10n/bundle.l10n.json @@ -209,6 +209,7 @@ "Profile is not authenticated, please log in to continue": "Profile is not authenticated, please log in to continue", "Retrieving response from USS list API": "Retrieving response from USS list API", "The 'move' function is not implemented for this USS API.": "The 'move' function is not implemented for this USS API.", + "Could not list USS files: Empty path provided in URI": "Could not list USS files: Empty path provided in URI", "Profile does not exist for this file.": "Profile does not exist for this file.", "Saving USS file...": "Saving USS file...", "Renaming {0} failed due to API error: {1}/File pathError message": { diff --git a/packages/zowe-explorer/l10n/poeditor.json b/packages/zowe-explorer/l10n/poeditor.json index b1fc3285e6..3dcc072f79 100644 --- a/packages/zowe-explorer/l10n/poeditor.json +++ b/packages/zowe-explorer/l10n/poeditor.json @@ -529,6 +529,7 @@ "Profile is not authenticated, please log in to continue": "", "Retrieving response from USS list API": "", "The 'move' function is not implemented for this USS API.": "", + "Could not list USS files: Empty path provided in URI": "", "Profile does not exist for this file.": "", "Saving USS file...": "", "Renaming {0} failed due to API error: {1}": "", diff --git a/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts b/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts index d73bd506e8..ab7f8722b9 100644 --- a/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts +++ b/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts @@ -129,18 +129,15 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv public async listFiles(profile: imperative.IProfileLoaded, uri: vscode.Uri, keepRelative: boolean = false): Promise { const queryParams = new URLSearchParams(uri.query); const ussPath = queryParams.has("searchPath") ? queryParams.get("searchPath") : uri.path.substring(uri.path.indexOf("/", 1)); - let response: IZosFilesResponse; - try { - response = await ZoweExplorerApiRegister.getUssApi(profile).fileList(ussPath); - // If request was successful, create directories for the path if it doesn't exist - if (response.success && !keepRelative && response.apiResponse.items?.[0]?.mode?.startsWith("d") && !this.exists(uri)) { - await vscode.workspace.fs.createDirectory(uri.with({ query: "" })); - } - } catch (err) { - if (err instanceof Error) { - ZoweLogger.error(err.message); - } - throw err; + if (ussPath.length === 0) { + throw new imperative.ImperativeError({ + msg: vscode.l10n.t("Could not list USS files: Empty path provided in URI"), + }); + } + const response = await ZoweExplorerApiRegister.getUssApi(profile).fileList(ussPath); + // If request was successful, create directories for the path if it doesn't exist + if (response.success && !keepRelative && response.apiResponse.items?.[0]?.mode?.startsWith("d") && !this.exists(uri)) { + await vscode.workspace.fs.createDirectory(uri.with({ query: "" })); } return {