Merge lp:~michihenning/storage-framework/add-trace into lp:storage-framework/devel

Proposed by Michi Henning
Status: Merged
Approved by: James Henstridge
Approved revision: 56
Merged at revision: 54
Proposed branch: lp:~michihenning/storage-framework/add-trace
Merge into: lp:storage-framework/devel
Diff against target: 361 lines (+197/-10)
10 files modified
CMakeLists.txt (+1/-0)
include/unity/storage/internal/TraceMessageHandler.h (+46/-0)
include/unity/storage/provider/internal/ServerImpl.h (+2/-0)
include/unity/storage/qt/client/internal/remote_client/Handler.h (+16/-1)
src/internal/CMakeLists.txt (+1/-0)
src/internal/TraceMessageHandler.cpp (+96/-0)
src/provider/internal/Handler.cpp (+29/-5)
src/provider/internal/ServerImpl.cpp (+4/-1)
src/qt/client/internal/remote_client/RuntimeImpl.cpp (+0/-1)
tests/provider-ProviderInterface/ProviderInterface_test.cpp (+2/-2)
To merge this branch: bzr merge lp:~michihenning/storage-framework/add-trace
Reviewer Review Type Date Requested Status
James Henstridge Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+302767@code.launchpad.net

Commit message

Added trace for surprising exceptions to server side and remote client.

Description of the change

Added trace for surprising exceptions to server side and remote client.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:55
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/76/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/374/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/380
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/297
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/297
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/297
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/227/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/227/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/227/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/227/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/227/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/227/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/227/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/227
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/227/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/227/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/76/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:55
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/77/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/375
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/381
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/298
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/298
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/298
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/228/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/228
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/228/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/77/rebuild

review: Approve (continuous-integration)
56. By Michi Henning

Logging surprising exceptions with qCritical() now.

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:56
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/78/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/389/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/395
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/310
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/310
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/310
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/240/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/240/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/240/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/240/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/240/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/240/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/240/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/240/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/240
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/240/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/78/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:56
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/79/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/390
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/396
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/311
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/311
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/311
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/241/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/241
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/241/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/79/rebuild

review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-08-11 02:03:32 +0000
3+++ CMakeLists.txt 2016-08-17 02:55:56 +0000
4@@ -130,6 +130,7 @@
5 enable_coverage_report(
6 TARGETS
7 qt-client-lib-common
8+ storage-framework-common-internal
9 storage-framework-qt-client
10 storage-framework-qt-local-client
11 sf-provider-objects
12
13=== added file 'include/unity/storage/internal/TraceMessageHandler.h'
14--- include/unity/storage/internal/TraceMessageHandler.h 1970-01-01 00:00:00 +0000
15+++ include/unity/storage/internal/TraceMessageHandler.h 2016-08-17 02:55:56 +0000
16@@ -0,0 +1,46 @@
17+/*
18+ * Copyright (C) 2015 Canonical Ltd
19+ *
20+ * This program is free software: you can redistribute it and/or modify
21+ * it under the terms of the GNU Lesser General Public License version 3 as
22+ * published by the Free Software Foundation.
23+ *
24+ * This program is distributed in the hope that it will be useful,
25+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+ * GNU Lesser General Public License for more details.
28+ *
29+ * You should have received a copy of the GNU Lesser General Public License
30+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
31+ *
32+ * Authors: Michi Henning <michi.henning@canonical.com>
33+ */
34+
35+#pragma once
36+
37+#pragma GCC diagnostic push
38+#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
39+#pragma GCC diagnostic ignored "-Wswitch-default"
40+#include <QDebug>
41+#pragma GCC diagnostic pop
42+
43+namespace unity
44+{
45+namespace storage
46+{
47+namespace internal
48+{
49+
50+class TraceMessageHandler final
51+{
52+public:
53+ TraceMessageHandler(std::string const& prog_name);
54+ ~TraceMessageHandler();
55+
56+private:
57+ QtMessageHandler old_message_handler_;
58+};
59+
60+} // namespace internal
61+} // namespace storage
62+} // namespace unity
63
64=== modified file 'include/unity/storage/provider/internal/ServerImpl.h'
65--- include/unity/storage/provider/internal/ServerImpl.h 2016-07-12 02:22:05 +0000
66+++ include/unity/storage/provider/internal/ServerImpl.h 2016-08-17 02:55:56 +0000
67@@ -19,6 +19,7 @@
68 #pragma once
69
70 #include <unity/storage/provider/Server.h>
71+#include <unity/storage/internal/TraceMessageHandler.h>
72 #include <unity/storage/provider/internal/DBusPeerCache.h>
73 #include <unity/storage/provider/internal/ProviderInterface.h>
74
75@@ -58,6 +59,7 @@
76 ServerBase* const server_;
77 std::string const bus_name_;
78 std::string const service_id_;
79+ unity::storage::internal::TraceMessageHandler trace_message_handler_;
80
81 std::unique_ptr<QCoreApplication> app_;
82 std::unique_ptr<OnlineAccounts::Manager> manager_;
83
84=== modified file 'include/unity/storage/qt/client/internal/remote_client/Handler.h'
85--- include/unity/storage/qt/client/internal/remote_client/Handler.h 2016-08-11 01:39:44 +0000
86+++ include/unity/storage/qt/client/internal/remote_client/Handler.h 2016-08-17 02:55:56 +0000
87@@ -80,10 +80,25 @@
88 auto ep = unmarshal_exception(call);
89 std::rethrow_exception(ep);
90 }
91+ // We catch some exceptions that are "surprising" so we can log those.
92+ catch (LocalCommsException const& e)
93+ {
94+ qCritical() << "provider exception:" << e.what();
95+ make_exceptional_future<T>(qf_, e);
96+ }
97+ catch (RemoteCommsException const& e)
98+ {
99+ qCritical() << "provider exception:" << e.what();
100+ make_exceptional_future<T>(qf_, e);
101+ }
102+ catch (ResourceException const& e)
103+ {
104+ qCritical() << "provider exception:" << e.what();
105+ make_exceptional_future<T>(qf_, e);
106+ }
107 catch (StorageException const& e)
108 {
109 make_exceptional_future<T>(qf_, e);
110- return;
111 }
112 // LCOV_EXCL_START
113 catch (...)
114
115=== modified file 'src/internal/CMakeLists.txt'
116--- src/internal/CMakeLists.txt 2016-08-11 06:53:25 +0000
117+++ src/internal/CMakeLists.txt 2016-08-17 02:55:56 +0000
118@@ -1,6 +1,7 @@
119 set(src
120 dbusmarshal.cpp
121 safe_strerror.cpp
122+ TraceMessageHandler.cpp
123 )
124
125 add_library(storage-framework-common-internal STATIC ${src})
126
127=== added file 'src/internal/TraceMessageHandler.cpp'
128--- src/internal/TraceMessageHandler.cpp 1970-01-01 00:00:00 +0000
129+++ src/internal/TraceMessageHandler.cpp 2016-08-17 02:55:56 +0000
130@@ -0,0 +1,96 @@
131+/*
132+ * Copyright (C) 2015 Canonical Ltd
133+ *
134+ * This program is free software: you can redistribute it and/or modify
135+ * it under the terms of the GNU Lesser General Public License version 3 as
136+ * published by the Free Software Foundation.
137+ *
138+ * This program is distributed in the hope that it will be useful,
139+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
140+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
141+ * GNU Lesser General Public License for more details.
142+ *
143+ * You should have received a copy of the GNU Lesser General Public License
144+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
145+ *
146+ * Authors: Michi Henning <michi.henning@canonical.com>
147+ */
148+
149+#include <unity/storage/internal/TraceMessageHandler.h>
150+
151+#include <chrono>
152+#include <mutex>
153+
154+using namespace std;
155+
156+namespace unity
157+{
158+namespace storage
159+{
160+namespace internal
161+{
162+namespace
163+{
164+
165+string prefix;
166+
167+void trace_message_handler(QtMsgType type, const QMessageLogContext& /*context*/, const QString& msg)
168+{
169+ using namespace std;
170+ using namespace std::chrono;
171+
172+ static recursive_mutex mutex;
173+ lock_guard<decltype(mutex)> lock(mutex);
174+
175+ auto now = system_clock::now();
176+ auto sys_time = system_clock::to_time_t(now);
177+ struct tm local_time;
178+ localtime_r(&sys_time, &local_time);
179+ int msecs = duration_cast<milliseconds>(now.time_since_epoch()).count() % 1000;
180+
181+ if (!prefix.empty())
182+ {
183+ fprintf(stderr, "%s: ", prefix.c_str());
184+ }
185+ char buf[100];
186+ strftime(buf, sizeof(buf), "%T", &local_time);
187+ fprintf(stderr, "[%s.%03d]", buf, msecs);
188+ switch (type)
189+ {
190+ case QtWarningMsg:
191+ fputs(" Warning:", stderr);
192+ break;
193+ case QtCriticalMsg:
194+ fputs(" Critical:", stderr);
195+ break;
196+ // LCOV_EXCL_START
197+ case QtFatalMsg:
198+ fputs(" Fatal:", stderr);
199+ break;
200+ // LCOV_EXCL_STOP
201+ default:
202+ break; // No label for debug messages.
203+ }
204+ fprintf(stderr, " %s\n", msg.toLocal8Bit().constData());
205+ if (type == QtFatalMsg)
206+ {
207+ abort(); // LCOV_EXCL_LINE
208+ }
209+}
210+
211+} // namespace
212+
213+TraceMessageHandler::TraceMessageHandler(string const& prog_name)
214+{
215+ prefix = prog_name;
216+ old_message_handler_ = qInstallMessageHandler(trace_message_handler);
217+}
218+
219+TraceMessageHandler::~TraceMessageHandler()
220+{
221+ qInstallMessageHandler(old_message_handler_);
222+}
223+
224+} // namespace internal
225+} // namespace storage
226+} // namespace unity
227
228=== modified file 'src/provider/internal/Handler.cpp'
229--- src/provider/internal/Handler.cpp 2016-08-11 01:39:44 +0000
230+++ src/provider/internal/Handler.cpp 2016-08-17 02:55:56 +0000
231@@ -26,6 +26,12 @@
232 #include <unity/storage/provider/ProviderBase.h>
233 #include <unity/storage/provider/Exceptions.h>
234
235+#pragma GCC diagnostic push
236+#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
237+#pragma GCC diagnostic ignored "-Wswitch-default"
238+#include <QDebug>
239+#pragma GCC diagnostic pop
240+
241 #include <stdexcept>
242
243 using namespace unity::storage::internal;
244@@ -65,7 +71,9 @@
245 }
246 else
247 {
248- auto ep = make_exception_ptr(PermissionException("Handler::begin(): could not retrieve credentials"));
249+ string msg = "Handler::begin(): could not retrieve credentials";
250+ qDebug() << QString::fromStdString(msg);
251+ auto ep = make_exception_ptr(PermissionException(msg));
252 marshal_exception(ep);
253 QMetaObject::invokeMethod(this, "send_reply",
254 Qt::QueuedConnection);
255@@ -82,6 +90,7 @@
256 }
257 catch (std::exception const& e)
258 {
259+ qDebug() << "provider method threw an exception:" << e.what();
260 marshal_exception(current_exception());
261 QMetaObject::invokeMethod(this, "send_reply", Qt::QueuedConnection);
262 return;
263@@ -94,8 +103,9 @@
264 {
265 reply_ = f.get();
266 }
267- catch (std::exception const&)
268+ catch (std::exception const& e)
269 {
270+ qDebug() << e.what();
271 marshal_exception(current_exception());
272 }
273 QMetaObject::invokeMethod(this, "send_reply", Qt::QueuedConnection);
274@@ -133,20 +143,34 @@
275 }
276 catch (ResourceException const& e)
277 {
278+ qDebug() << e.what();
279 reply_ << QVariant(e.error_code());
280 }
281+ catch (RemoteCommsException const& e)
282+ {
283+ qDebug() << e.what();
284+ }
285+ catch (UnknownException const& e)
286+ {
287+ qDebug() << e.what();
288+ }
289 catch (StorageException const&)
290 {
291- // Some other sub-type of StorageException without additional data members.
292+ // Some other sub-type of StorageException without additional data members,
293+ // and we don't want to log this (not surprising) exception.
294 }
295 }
296 catch (std::exception const& e)
297 {
298- reply_ = message_.createErrorReply(QString(DBUS_ERROR_PREFIX) + "UnknownException", e.what());
299+ QString msg = QString("unknown exception thrown by provider: ") + e.what();
300+ qDebug() << msg;
301+ reply_ = message_.createErrorReply(QString(DBUS_ERROR_PREFIX) + "UnknownException", msg);
302 }
303 catch (...)
304 {
305- reply_ = message_.createErrorReply(QString(DBUS_ERROR_PREFIX) + "UnknownException", "unknown exception type");
306+ QString msg = "unknown exception thrown by provider";
307+ qDebug() << msg;
308+ reply_ = message_.createErrorReply(QString(DBUS_ERROR_PREFIX) + "UnknownException", msg);
309 }
310 }
311
312
313=== modified file 'src/provider/internal/ServerImpl.cpp'
314--- src/provider/internal/ServerImpl.cpp 2016-08-12 01:34:34 +0000
315+++ src/provider/internal/ServerImpl.cpp 2016-08-17 02:55:56 +0000
316@@ -38,7 +38,10 @@
317 {
318
319 ServerImpl::ServerImpl(ServerBase* server, string const& bus_name, string const& account_service_id)
320- : server_(server), bus_name_(bus_name), service_id_(account_service_id)
321+ : server_(server)
322+ , bus_name_(bus_name)
323+ , service_id_(account_service_id)
324+ , trace_message_handler_("storage_provider")
325 {
326 qDBusRegisterMetaType<Item>();
327 qDBusRegisterMetaType<std::vector<Item>>();
328
329=== modified file 'src/qt/client/internal/remote_client/RuntimeImpl.cpp'
330--- src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-12 00:01:19 +0000
331+++ src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-17 02:55:56 +0000
332@@ -139,7 +139,6 @@
333 {
334 for (auto const& a : manager_->availableAccounts(service_id))
335 {
336- qDebug() << "got account:" << a->displayName() << a->serviceId() << a->id();
337 auto object_path = QStringLiteral("/provider/%1").arg(a->id());
338 accounts.append(make_account(BUS_NAME, object_path,
339 "", a->serviceId(), a->displayName()));
340
341=== modified file 'tests/provider-ProviderInterface/ProviderInterface_test.cpp'
342--- tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-12 01:34:34 +0000
343+++ tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-17 02:55:56 +0000
344@@ -398,7 +398,7 @@
345 wait_for(reply);
346 ASSERT_TRUE(reply.isError());
347 EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());
348- EXPECT_EQ("map::at", reply.error().message());
349+ EXPECT_EQ("unknown exception thrown by provider: map::at", reply.error().message());
350 }
351
352 TEST_F(ProviderInterfaceTest, download)
353@@ -472,7 +472,7 @@
354 wait_for(reply);
355 ASSERT_TRUE(reply.isError());
356 EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());
357- EXPECT_EQ("map::at", reply.error().message());
358+ EXPECT_EQ("unknown exception thrown by provider: map::at", reply.error().message());
359 }
360
361 TEST_F(ProviderInterfaceTest, delete_)

Subscribers

People subscribed via source and target branches

to all changes: