From 0b84e108971a9a12373bbad5e91c1656cdd9f59b Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Thu, 29 Jun 2017 10:31:44 -0400
Subject: [PATCH] ringaccount: display clearly when no device is found

* Log when a call fails due to "0 devices found" condition.
* Report an error code (no_such_device_or_address)
  to the call failure method.
* Use dgb than warn when devices are found.

Change-Id: Ie3ffa4fc1c9ebf2fea3453c647890a108213bd00
---
 src/ringdht/ringaccount.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index 70fbd6a1ca..840c77147b 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -75,6 +75,7 @@
 #include <cctype>
 #include <cstdarg>
 #include <string>
+#include <system_error>
 
 namespace ring {
 
@@ -486,7 +487,7 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
     {
         auto call = wCall.lock();
         if (not call) return;
-        RING_WARN("[call %s] Found device %s", call->getCallId().c_str(), dev.toString().c_str());
+        RING_DBG("[call %s] calling device %s", call->getCallId().c_str(), dev.toString().c_str());
 
         auto& manager = Manager::instance();
         auto dev_call = manager.callFactory.newCall<SIPCall, RingAccount>(*sthis, manager.getNewCallID(),
@@ -572,8 +573,10 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
         });
     }, [=](bool ok){
         if (not ok) {
-            if (auto call = wCall.lock())
-                call->onFailure();
+            if (auto call = wCall.lock()) {
+                RING_WARN("[call:%s] no devices found", call->getCallId().c_str());
+                call->onFailure(static_cast<int>(std::errc::no_such_device_or_address));
+            }
         }
     });
 }
-- 
GitLab