Allow steps to fail with error message
Summary: Add a method to add error messages into failed steps. This will be surfaced in the diagnostic screen, to help the user troubleshoot. Reviewed By: passy Differential Revision: D9333322 fbshipit-source-id: 5f1e55c3d71b19292dbc428aaecfbd41e7a75125
This commit is contained in:
committed by
Facebook Github Bot
parent
dfcfa9f7fa
commit
38391ca29e
@@ -41,7 +41,7 @@ void SonarState::success(std::string step) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SonarState::failed(std::string step, std::string errorMessage) {
|
void SonarState::failed(std::string step, std::string errorMessage) {
|
||||||
log = log + "[Failed] " + step + "\n";
|
log = log + "[Failed] " + step + ": " + errorMessage + "\n";
|
||||||
stateMap[step] = State::failed;
|
stateMap[step] = State::failed;
|
||||||
if (mListener) {
|
if (mListener) {
|
||||||
mListener->onUpdate();
|
mListener->onUpdate();
|
||||||
|
|||||||
@@ -9,17 +9,22 @@
|
|||||||
#include "SonarState.h"
|
#include "SonarState.h"
|
||||||
|
|
||||||
void SonarStep::complete() {
|
void SonarStep::complete() {
|
||||||
isCompleted = true;
|
isLogged = true;
|
||||||
state->success(name);
|
state->success(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SonarStep::fail(std::string message) {
|
||||||
|
isLogged = true;
|
||||||
|
state->failed(name, message);
|
||||||
|
}
|
||||||
|
|
||||||
SonarStep::SonarStep(std::string step, SonarState* s) {
|
SonarStep::SonarStep(std::string step, SonarState* s) {
|
||||||
state = s;
|
state = s;
|
||||||
name = step;
|
name = step;
|
||||||
}
|
}
|
||||||
|
|
||||||
SonarStep::~SonarStep() {
|
SonarStep::~SonarStep() {
|
||||||
if (!isCompleted) {
|
if (!isLogged) {
|
||||||
state->failed(name, "");
|
state->failed(name, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ class SonarState;
|
|||||||
class SonarStep {
|
class SonarStep {
|
||||||
public:
|
public:
|
||||||
void complete();
|
void complete();
|
||||||
|
void fail(std::string message);
|
||||||
SonarStep(std::string name, SonarState* state);
|
SonarStep(std::string name, SonarState* state);
|
||||||
~SonarStep();
|
~SonarStep();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
bool isCompleted = false;
|
bool isLogged = false;
|
||||||
SonarState* state;
|
SonarState* state;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -123,19 +123,23 @@ void SonarWebSocketImpl::startSync() {
|
|||||||
doCertificateExchange();
|
doCertificateExchange();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connectSecurely();
|
|
||||||
|
|
||||||
|
connectSecurely();
|
||||||
connect->complete();
|
connect->complete();
|
||||||
} catch (const folly::AsyncSocketException& e) {
|
} catch (const folly::AsyncSocketException& e) {
|
||||||
if (e.getType() == folly::AsyncSocketException::NOT_OPEN) {
|
if (e.getType() == folly::AsyncSocketException::NOT_OPEN) {
|
||||||
// The expected code path when flipper desktop is not running.
|
// The expected code path when flipper desktop is not running.
|
||||||
|
// Don't count as a failed attempt.
|
||||||
|
connect->fail("Port not open");
|
||||||
} else {
|
} else {
|
||||||
SONAR_LOG(e.what());
|
SONAR_LOG(e.what());
|
||||||
failedConnectionAttempts_++;
|
failedConnectionAttempts_++;
|
||||||
|
connect->fail(e.what());
|
||||||
}
|
}
|
||||||
reconnect();
|
reconnect();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
SONAR_LOG(e.what());
|
SONAR_LOG(e.what());
|
||||||
|
connect->fail(e.what());
|
||||||
failedConnectionAttempts_++;
|
failedConnectionAttempts_++;
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user