diff --git a/packages/plugin-ext/src/common/rpc-protocol.ts b/packages/plugin-ext/src/common/rpc-protocol.ts index eb335c80ba971..8947841cd1657 100644 --- a/packages/plugin-ext/src/common/rpc-protocol.ts +++ b/packages/plugin-ext/src/common/rpc-protocol.ts @@ -552,6 +552,7 @@ function safeStringify(obj: any, replacer?: JSONStringifyReplacer): string { try { return JSON.stringify(obj, replacer); } catch (err) { + console.error('error stringifying response: ', err); return 'null'; } } diff --git a/packages/plugin-ext/src/plugin/command-registry.ts b/packages/plugin-ext/src/plugin/command-registry.ts index cc19a98b0d5e4..a5e877d93256f 100644 --- a/packages/plugin-ext/src/plugin/command-registry.ts +++ b/packages/plugin-ext/src/plugin/command-registry.ts @@ -129,7 +129,7 @@ export class CommandRegistryImpl implements CommandRegistryExt { if (handler) { return handler(...args.map(arg => this.argumentProcessors.reduce((r, p) => p.processArgument(r), arg))); } else { - throw new Error(`Command ${id} doesn't exist`); + throw new Error(`No handler exists for command '${id}'`); } } @@ -171,6 +171,7 @@ export class CommandsConverter { if (!command) { return undefined; } + const result = this.toInternalCommand(command); if (KnownCommands.mapped(result.id)) { return result; @@ -181,7 +182,7 @@ export class CommandsConverter { this.isSafeCommandRegistered = true; } - if (command.command && command.arguments && command.arguments.length > 0) { + if (command.arguments && command.arguments.length > 0) { const id = this.handle++; this.commandsMap.set(id, command); disposables.push(new Disposable(() => this.commandsMap.delete(id))); @@ -197,19 +198,19 @@ export class CommandsConverter { // Existing code will have compiled against a non - optional version of the field, so asserting it to exist is ok // eslint-disable-next-line @typescript-eslint/no-explicit-any return KnownCommands.map((external.command || external.id)!, external.arguments, (mappedId: string, mappedArgs: any[]) => - ({ - id: mappedId, - title: external.title || external.label || ' ', - tooltip: external.tooltip, - arguments: mappedArgs - })); + ({ + id: mappedId, + title: external.title || external.label || ' ', + tooltip: external.tooltip, + arguments: mappedArgs + })); } // eslint-disable-next-line @typescript-eslint/no-explicit-any private executeSafeCommand(...args: any[]): PromiseLike { const command = this.commandsMap.get(args[0]); if (!command || !command.command) { - return Promise.reject('command NOT FOUND'); + return Promise.reject(`command ${args[0]} not found`); } return this.commands.executeCommand(command.command, ...(command.arguments || [])); }