Skip to content

Commit 93eef46

Browse files
check if requested local data file exists (#99)
prior to executing view table command for it, and show and error message.
1 parent f89f047 commit 93eef46

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/commands/openDataFile.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Uri
77
} from 'vscode';
88

9+
import * as fs from 'fs';
910
import * as path from 'path';
1011

1112
import { ViewCommands } from './viewCommands';
@@ -31,8 +32,12 @@ export async function registerOpenDataFileCommand(context: ExtensionContext) {
3132
`Tabular Data Viewer requires a valid \`file:///\` or \`https://\` data file Url \
3233
to display Table View. Invalid data document Url: \`${dataFileUrl}\`.`);
3334
}
35+
else if (dataFileUrl?.startsWith('file:///') && !fs.existsSync(dataFileUri.fsPath)) {
36+
window.showErrorMessage(
37+
`Unable to locate requested data file: \`${dataFileUrl}\`.`);
38+
}
3439
else if ((<any>Object).values(FileTypes).includes(fileExtension)) {
35-
// open table view for the data file
40+
// open table view for requested remote or local data file
3641
commands.executeCommand(ViewCommands.viewTable, dataFileUri);
3742
}
3843
else if (fileExtension.length === 0) {

0 commit comments

Comments
 (0)