From 77905f30c857a4ae6521c9be2972ffe31593e9b7 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Fri, 24 Mar 2023 04:28:58 -0700 Subject: [PATCH] Add context to AbstractClient rawCall errors Summary: Attempting to fix T146503217. There is no context to the error so this should make it easier in the future. In the MID it says that the layout plugin was selected i made sure to handle any promise rejections in that plugin Reviewed By: passy Differential Revision: D44302939 fbshipit-source-id: 987e2c4efd2dc47d2e032d1b21f90458ec5a2df5 --- desktop/flipper-frontend-core/src/AbstractClient.tsx | 7 +++++-- desktop/plugins/public/layout/Inspector.tsx | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/desktop/flipper-frontend-core/src/AbstractClient.tsx b/desktop/flipper-frontend-core/src/AbstractClient.tsx index 4b831f134..0730a3bf1 100644 --- a/desktop/flipper-frontend-core/src/AbstractClient.tsx +++ b/desktop/flipper-frontend-core/src/AbstractClient.tsx @@ -357,6 +357,9 @@ export default abstract class AbstractClient extends EventEmitter { const plugin = params ? params.api : undefined; + const baseErrorMessage = `Unable to send ${params?.method ?? method} to ${ + params?.api ?? 'FlipperCore' + }`; console.debug(data, 'message:call'); const mark = this.getPerformanceMark(metadata); @@ -391,12 +394,12 @@ export default abstract class AbstractClient extends EventEmitter { }); } } catch (error) { - reject(new Error('Unable to send, connection error: ' + error)); + reject(new Error(`${baseErrorMessage}, connection error: ${error}`)); } } else { reject( new Error( - `Cannot send ${method}, client is not accepting messages for plugin ${plugin}`, + `${baseErrorMessage}, client is not accepting messages for plugin ${plugin}`, ), ); } diff --git a/desktop/plugins/public/layout/Inspector.tsx b/desktop/plugins/public/layout/Inspector.tsx index cb3d0f0bf..96d7054e9 100644 --- a/desktop/plugins/public/layout/Inspector.tsx +++ b/desktop/plugins/public/layout/Inspector.tsx @@ -108,7 +108,9 @@ export default class Inspector extends Component { label: 'Focus', click: (id: ElementID) => { if (this.props.client.isConnected) { - this.props.client.call('onRequestAXFocus', {id}); + this.props.client + .call('onRequestAXFocus', {id}) + .catch((e) => console.warn('Unable to request AX focus', e)); } }, },