Skip to content

Commit b1c516d

Browse files
trap and show data package parse/load errors (#104)
when loading data package info to list tabular data resources
1 parent ee8f6ef commit b1c516d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/commands/listDataResources.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,17 @@ async function listDataResources(dataPackageUri: Uri): Promise<void> {
4848
dataPackageUrl = dataPackageUri.fsPath;
4949
}
5050

51-
// load data package
52-
const dataPackage: any = await DataPackage.Package.load(dataPackageUrl);
53-
// console.log('tabular.data.package:', dataPackage);
54-
// console.log('tabular.data.package.resources:', dataPackage.resources);
51+
let dataPackage: any = undefined;
52+
try {
53+
// load data package
54+
dataPackage = await DataPackage.Package.load(dataPackageUrl);
55+
// console.log('tabular.data.package:', dataPackage);
56+
// console.log('tabular.data.package.resources:', dataPackage.resources);
57+
}
58+
catch (error: any) {
59+
window.showErrorMessage(error.message);
60+
return;
61+
}
5562

5663
// get data package resources
5764
const dataResources: Array<QuickPickItem> = [];
@@ -61,7 +68,7 @@ async function listDataResources(dataPackageUri: Uri): Promise<void> {
6168

6269
// construct github repository resource Url
6370
let resourceUrl: string = fileUtils.convertToGitHubRepositoryUrl(resource.source);
64-
71+
6572
if (dataPackageUri.scheme === 'file') {
6673
// create local resource path using data package Uri as resource base path
6774
const resourceUri: Uri = Uri.joinPath(dataPackageUri, `../${resource.source}`);

0 commit comments

Comments
 (0)