Fix eagerly rejection ADB spawn error
Summary: Fix unnecessary unhandled promise rejection. Reviewed By: passy Differential Revision: D31267305 fbshipit-source-id: 90b22fdfa1721f10ad92dbeca74c2ee1988ac15c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
816720d708
commit
e32a377c65
@@ -99,7 +99,10 @@ export default class CertificateProvider {
|
|||||||
|
|
||||||
get adb(): Promise<ADBClient> {
|
get adb(): Promise<ADBClient> {
|
||||||
if (this.config.enableAndroid) {
|
if (this.config.enableAndroid) {
|
||||||
return this._adb!;
|
if (this._adb) {
|
||||||
|
return this._adb;
|
||||||
|
}
|
||||||
|
throw new Error(`ADB initialisation was not not successful`);
|
||||||
}
|
}
|
||||||
throw new Error('Android is not enabled in settings');
|
throw new Error('Android is not enabled in settings');
|
||||||
}
|
}
|
||||||
@@ -114,14 +117,15 @@ export default class CertificateProvider {
|
|||||||
this._adb = config.enableAndroid
|
this._adb = config.enableAndroid
|
||||||
? (getAdbClient(config).catch((e) => {
|
? (getAdbClient(config).catch((e) => {
|
||||||
// make sure initialization failure is already logged
|
// make sure initialization failure is already logged
|
||||||
|
const msg =
|
||||||
|
'Failed to initialise ADB. Please disabled Android supportin settings, or configure a correct path';
|
||||||
message.error({
|
message.error({
|
||||||
duration: 10,
|
duration: 10,
|
||||||
content:
|
content: msg + e,
|
||||||
'Failed to initialise ADB. Please check your Android settings, ANDROID_HOME and run the Setup Doctor. ' +
|
|
||||||
e,
|
|
||||||
});
|
});
|
||||||
console.error('Failed to initialise ADB', e);
|
// eslint-disable-next-line flipper/no-console-error-without-context
|
||||||
this._adb = Promise.reject(e);
|
console.error(msg, e);
|
||||||
|
this._adb = undefined; // no adb client available
|
||||||
}) as Promise<ADBClient>)
|
}) as Promise<ADBClient>)
|
||||||
: undefined;
|
: undefined;
|
||||||
if (isTest()) {
|
if (isTest()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user