Send crash notification when flipper cpp exceptions are suppressed
Summary: This diff adds support to send crash notification whenever the cpp exception of Flipper is suppressed. Also updated the tests regarding the same Reviewed By: jknoxville Differential Revision: D13635822 fbshipit-source-id: 01e4a57c391476e5b044e64946d337cb4582a527
This commit is contained in:
committed by
Facebook Github Bot
parent
944a197cf6
commit
87f64c4535
@@ -27,8 +27,43 @@ export type ClientQuery = {|
|
||||
device_id: string,
|
||||
|};
|
||||
|
||||
type ErrorType = {message: string, stacktrace: string, name: string};
|
||||
type RequestMetadata = {method: string, id: number, params: ?Object};
|
||||
|
||||
const handleError = (store: Store, deviceSerial: ?string, error: ErrorType) => {
|
||||
const crashReporterPlugin = store
|
||||
.getState()
|
||||
.plugins.devicePlugins.get('CrashReporter');
|
||||
if (!crashReporterPlugin) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pluginKey = `${deviceSerial || ''}#CrashReporter`;
|
||||
|
||||
const persistedState = {
|
||||
...crashReporterPlugin.defaultPersistedState,
|
||||
...store.getState().pluginStates[pluginKey],
|
||||
};
|
||||
// $FlowFixMe: We checked persistedStateReducer exists
|
||||
const newPluginState = crashReporterPlugin.persistedStateReducer(
|
||||
persistedState,
|
||||
'flipper-crash-report',
|
||||
{
|
||||
name: error.name,
|
||||
reason: error.message,
|
||||
callstack: error.stacktrace,
|
||||
},
|
||||
);
|
||||
if (persistedState !== newPluginState) {
|
||||
store.dispatch(
|
||||
setPluginState({
|
||||
pluginKey,
|
||||
state: newPluginState,
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default class Client extends EventEmitter {
|
||||
constructor(
|
||||
id: string,
|
||||
@@ -162,6 +197,7 @@ export default class Client extends EventEmitter {
|
||||
}: ${error.message} + \nDevice Stack Trace: ${error.stacktrace}`,
|
||||
'deviceError',
|
||||
);
|
||||
handleError(this.store, this.getDevice()?.serial, error);
|
||||
} else if (method === 'refreshPlugins') {
|
||||
this.refreshPlugins();
|
||||
} else if (method === 'execute') {
|
||||
@@ -226,6 +262,10 @@ export default class Client extends EventEmitter {
|
||||
callbacks.resolve(data.success);
|
||||
} else if (data.error) {
|
||||
callbacks.reject(data.error);
|
||||
const {error} = data;
|
||||
if (error) {
|
||||
handleError(this.store, this.getDevice()?.serial, error);
|
||||
}
|
||||
} else {
|
||||
// ???
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user