From 31ecc5170e0a0a7bd8fb01b50b39abb74633297e Mon Sep 17 00:00:00 2001 From: Utkarsh Shigihalli Date: Mon, 21 Oct 2019 22:45:06 +0100 Subject: [PATCH] fix #1 --- src/extension.ts | 2 +- src/util.ts | 6 ++++-- src/vsixOutlineProvider.ts | 16 +++++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index d680fdd..e260295 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -12,7 +12,7 @@ export function activate(context: vscode.ExtensionContext) { vscode.window.showWarningMessage("Please right click on a VSIX file in the Explorer and select 'Show in VSIX Viewer'."); return; } - TelemetryClient.instance.sendEvent("showInVSIXViewer"); + TelemetryClient.instance.sendEvent("showInVSIXViewerClicked"); const vsixOutlineProvider = new VsixOutlineProvider(context, selectedFile.fsPath); vscode.window.registerTreeDataProvider("vsixViewer", vsixOutlineProvider); diff --git a/src/util.ts b/src/util.ts index 8a715f9..eab6c4b 100644 --- a/src/util.ts +++ b/src/util.ts @@ -15,7 +15,9 @@ export default class Util { return Util._instance; } - public log(message: string) { - this._channel.appendLine(message); + public log(message: string | undefined) { + if (message) { + this._channel.appendLine(message); + } } } \ No newline at end of file diff --git a/src/vsixOutlineProvider.ts b/src/vsixOutlineProvider.ts index adf00f6..b2f018d 100644 --- a/src/vsixOutlineProvider.ts +++ b/src/vsixOutlineProvider.ts @@ -31,10 +31,15 @@ export class VsixOutlineProvider implements vscode.TreeDataProvider { async getChildren(element?: VsixItem): Promise { if (!element) { - Util.instance.log("Getting contents of VSIX"); - let root = await this.parseVsix(this._vsixPath); - this.sort(root); - return Promise.resolve([root]); + try { + Util.instance.log("Getting contents of VSIX"); + let root = await this.parseVsix(this._vsixPath); + this.sort(root); + return Promise.resolve([root]); + } catch (error) { + vscode.window.showErrorMessage(`An error ocurred while parsing VSIX: ${error}`); + return Promise.resolve([]); + } } else { return Promise.resolve(element.children); @@ -122,9 +127,10 @@ export class VsixOutlineProvider implements vscode.TreeDataProvider { fs.readFile(this._vsixPath, function (err, data) { if (err) { Util.instance.log("Error occurred while reading VSIX"); - Util.instance.log(err.message); + Util.instance.log(err.stack); TelemetryClient.instance.sendError(err); reject(err); + return; } jszip.loadAsync(data, { createFolders: true