diff --git a/desktop/flipper-plugin/src/__tests__/test-utils.node.tsx b/desktop/flipper-plugin/src/__tests__/test-utils.node.tsx index b3ab3c7d1..6e5f6f667 100644 --- a/desktop/flipper-plugin/src/__tests__/test-utils.node.tsx +++ b/desktop/flipper-plugin/src/__tests__/test-utils.node.tsx @@ -166,7 +166,9 @@ test('a plugin cannot send messages after being disconnected', async () => { await instance.getCurrentState(); } catch (e) { threw = true; // for some weird reason expect(async () => instance.getCurrentState()).toThrow(...) doesn't work today... - expect(e).toMatchInlineSnapshot(`[Error: Plugin is not connected]`); + expect(e).toMatchInlineSnapshot( + `[Error: SandyPluginInstance.assertConnected -> plugin is not connected]`, + ); } expect(threw).toBeTruthy(); }); diff --git a/desktop/flipper-plugin/src/plugin/Plugin.tsx b/desktop/flipper-plugin/src/plugin/Plugin.tsx index aa8aa4d44..c7fd847f5 100644 --- a/desktop/flipper-plugin/src/plugin/Plugin.tsx +++ b/desktop/flipper-plugin/src/plugin/Plugin.tsx @@ -292,14 +292,26 @@ export class SandyPluginInstance extends BasePluginInstance { private assertConnected() { this.assertNotDestroyed(); - if ( - // This is a better-safe-than-sorry; just the first condition should suffice - !this.connected.get() || - !this.realClient.connected.get() || - !this.device.isConnected || - this.device.isArchived - ) { - throw new Error('Plugin is not connected'); + // This is a better-safe-than-sorry; just the first condition should suffice + if (!this.connected.get()) { + throw new Error( + 'SandyPluginInstance.assertConnected -> plugin is not connected', + ); + } + if (!this.realClient.connected.get()) { + throw new Error( + 'SandyPluginInstance.assertConnected -> realClient is not connected', + ); + } + if (!this.device.isConnected) { + throw new Error( + 'SandyPluginInstance.assertConnected -> device is not connected', + ); + } + if (this.device.isArchived) { + throw new Error( + 'SandyPluginInstance.assertConnected -> device is archived', + ); } } }