diff --git a/xplat/Sonar/SonarState.cpp b/xplat/Sonar/SonarState.cpp index 75a1195c8..9df342634 100644 --- a/xplat/Sonar/SonarState.cpp +++ b/xplat/Sonar/SonarState.cpp @@ -41,7 +41,7 @@ void SonarState::success(std::string step) { } void SonarState::failed(std::string step, std::string errorMessage) { - log = log + "[Failed] " + step + "\n"; + log = log + "[Failed] " + step + ": " + errorMessage + "\n"; stateMap[step] = State::failed; if (mListener) { mListener->onUpdate(); diff --git a/xplat/Sonar/SonarStep.cpp b/xplat/Sonar/SonarStep.cpp index 74475394f..46c1fe7e3 100644 --- a/xplat/Sonar/SonarStep.cpp +++ b/xplat/Sonar/SonarStep.cpp @@ -9,17 +9,22 @@ #include "SonarState.h" void SonarStep::complete() { - isCompleted = true; + isLogged = true; state->success(name); } +void SonarStep::fail(std::string message) { + isLogged = true; + state->failed(name, message); +} + SonarStep::SonarStep(std::string step, SonarState* s) { state = s; name = step; } SonarStep::~SonarStep() { - if (!isCompleted) { + if (!isLogged) { state->failed(name, ""); } } diff --git a/xplat/Sonar/SonarStep.h b/xplat/Sonar/SonarStep.h index 37bfef11a..afb18923a 100644 --- a/xplat/Sonar/SonarStep.h +++ b/xplat/Sonar/SonarStep.h @@ -15,11 +15,12 @@ class SonarState; class SonarStep { public: void complete(); + void fail(std::string message); SonarStep(std::string name, SonarState* state); ~SonarStep(); private: std::string name; - bool isCompleted = false; + bool isLogged = false; SonarState* state; }; diff --git a/xplat/Sonar/SonarWebSocketImpl.cpp b/xplat/Sonar/SonarWebSocketImpl.cpp index 8ee31fb5a..8b31085d6 100644 --- a/xplat/Sonar/SonarWebSocketImpl.cpp +++ b/xplat/Sonar/SonarWebSocketImpl.cpp @@ -123,19 +123,23 @@ void SonarWebSocketImpl::startSync() { doCertificateExchange(); return; } - connectSecurely(); + connectSecurely(); connect->complete(); } catch (const folly::AsyncSocketException& e) { if (e.getType() == folly::AsyncSocketException::NOT_OPEN) { // The expected code path when flipper desktop is not running. + // Don't count as a failed attempt. + connect->fail("Port not open"); } else { SONAR_LOG(e.what()); failedConnectionAttempts_++; + connect->fail(e.what()); } reconnect(); } catch (const std::exception& e) { SONAR_LOG(e.what()); + connect->fail(e.what()); failedConnectionAttempts_++; reconnect(); }