Unify error notifications (#1483)
Summary: Note: this is to be stacked upon https://github.com/facebook/flipper/pull/1479 Note: this PR will probably not succeed against FB internal flipper, as I'm pretty sure there are more call sites that need to be updated. So consider this WIP Currently connection errors are managed in the connection reducers, and are displayed through their own means, the error bar. Showing console.errors is also hooked up to this mechanism in FB internal flipper, but not at all in the OSS version, which means that some connection errors are never shown to the user. Besides that there is a notification system that is used by for example the crash reporter and plugin updater. Having effectively (at least) two notifications mechanisms is confusing and error prone. This PR unifies both approaches, and rather than having the connection reducer manage it's own errors, it leverages the more generic notifications reducer. Since, in the previous PR, console errors and warnings have become user facing (even in OSS and production builds, which wasn't the case before), there is no need anymore for a separate error bar. I left the notifications mechanism itself as-is, but as discussed in the Sandy project the notification screen will probably be overhauled, and the system wide notifications will become in-app notifications. ## Changelog Pull Request resolved: https://github.com/facebook/flipper/pull/1483 Test Plan: Only updated the unit tests at this point. Manual tests still need to be done. Reviewed By: passy Differential Revision: D23220896 Pulled By: mweststrate fbshipit-source-id: 8ea37cf69ce9605dc232ca90afe9e2f70da26652
This commit is contained in:
committed by
Facebook GitHub Bot
parent
76b72f3d77
commit
81eb09e7b0
@@ -19,7 +19,7 @@ import which from 'which';
|
||||
import {promisify} from 'util';
|
||||
import {ServerPorts} from '../reducers/application';
|
||||
import {Client as ADBClient} from 'adbkit';
|
||||
import {addNotification} from '../reducers/notifications';
|
||||
import {addErrorNotification} from '../reducers/notifications';
|
||||
|
||||
function createDevice(
|
||||
adbClient: ADBClient,
|
||||
@@ -84,22 +84,14 @@ function createDevice(
|
||||
const isAuthorizationError = (e?.message as string)?.includes(
|
||||
'device unauthorized',
|
||||
);
|
||||
console.error('Failed to initialize device: ' + device.id, e);
|
||||
store.dispatch(
|
||||
addNotification({
|
||||
client: null,
|
||||
notification: {
|
||||
id: 'androidDeviceConnectionError' + device.id,
|
||||
title: 'Could not connect to ' + device.id,
|
||||
severity: 'error',
|
||||
message: `Failed to connect to '${device.id}': ${
|
||||
isAuthorizationError
|
||||
? 'make sure to authorize debugging on the phone'
|
||||
: JSON.stringify(e, null, 2)
|
||||
}`,
|
||||
},
|
||||
pluginId: 'androidDevice',
|
||||
}),
|
||||
addErrorNotification(
|
||||
'Could not connect to ' + device.id,
|
||||
isAuthorizationError
|
||||
? 'Make sure to authorize debugging on the phone'
|
||||
: 'Failed to setup connection',
|
||||
e,
|
||||
),
|
||||
);
|
||||
}
|
||||
resolve(undefined); // not ready yet, we will find it in the next tick
|
||||
|
||||
Reference in New Issue
Block a user