Merge lp:~pete-woods/libusermetrics/robust-qml into lp:libusermetrics

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 135
Merged at revision: 135
Proposed branch: lp:~pete-woods/libusermetrics/robust-qml
Merge into: lp:libusermetrics
Diff against target: 167 lines (+64/-19)
3 files modified
po/en_GB.po (+17/-4)
po/libusermetrics.pot (+17/-1)
src/modules/UserMetrics/Metric.cpp (+30/-14)
To merge this branch: bzr merge lp:~pete-woods/libusermetrics/robust-qml
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity Team Pending
Review via email: mp+187816@code.launchpad.net

Commit message

Handle exceptions in the QML API

Description of the change

Handle exceptions in the QML API

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/en_GB.po'
2--- po/en_GB.po 2013-09-25 10:12:27 +0000
3+++ po/en_GB.po 2013-09-26 15:27:09 +0000
4@@ -2,12 +2,11 @@
5 # This file is distributed under the same license as the libusermetrics package.
6 # Pete Woods <pete.woods@canonical.com>, 2013.
7 #
8-#, fuzzy
9 msgid ""
10 msgstr ""
11 "Project-Id-Version: libusermetrics\n"
12 "Report-Msgid-Bugs-To: \n"
13-"POT-Creation-Date: 2013-09-25 11:09+0100\n"
14+"POT-Creation-Date: 2013-09-26 16:22+0100\n"
15 "PO-Revision-Date: 2013-07-05 15:09+0100\n"
16 "Last-Translator: Pete Woods <pete.woods@canonical.com>\n"
17 "Language-Team: British English <en@li.org>\n"
18@@ -30,7 +29,6 @@
19 msgstr "Attempt to create data source owned by another application"
20
21 #: src/usermetricsservice/DBusUserMetrics.cpp:241
22-#, fuzzy
23 msgid "Attempt to create user data owned by another user"
24 msgstr "Attempt to create user data owned by another user"
25
26@@ -85,7 +83,6 @@
27 msgstr "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME <DATA>"
28
29 #: src/libusermetricsinput/main-increment.cpp:37
30-#, fuzzy
31 msgid "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME [AMOUNT]"
32 msgstr "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME [AMOUNT]"
33
34@@ -101,6 +98,22 @@
35 msgid "Data source query failed"
36 msgstr "Data source query failed"
37
38+#: src/modules/UserMetrics/Metric.cpp:28
39+msgid "Failed to connect to metrics service:"
40+msgstr "Failed to connect to metrics service:"
41+
42+#: src/modules/UserMetrics/Metric.cpp:115
43+msgid "Failed to increment metric:"
44+msgstr ""
45+
46+#: src/modules/UserMetrics/Metric.cpp:102
47+msgid "Failed to register user metric:"
48+msgstr "Failed to register user metric:"
49+
50+#: src/modules/UserMetrics/Metric.cpp:127
51+msgid "Failed to update metric:"
52+msgstr "Failed to update metric:"
53+
54 #: src/usermetricsservice/DBusUserData.cpp:132
55 msgid "New data set could not be found"
56 msgstr "New data set couldn't be found"
57
58=== modified file 'po/libusermetrics.pot'
59--- po/libusermetrics.pot 2013-09-25 10:12:27 +0000
60+++ po/libusermetrics.pot 2013-09-26 15:27:09 +0000
61@@ -8,7 +8,7 @@
62 msgstr ""
63 "Project-Id-Version: libusermetrics\n"
64 "Report-Msgid-Bugs-To: \n"
65-"POT-Creation-Date: 2013-09-25 11:09+0100\n"
66+"POT-Creation-Date: 2013-09-26 16:22+0100\n"
67 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
68 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
69 "Language-Team: LANGUAGE <LL@li.org>\n"
70@@ -111,6 +111,22 @@
71 msgid "New data set could not be found"
72 msgstr ""
73
74+#: src/modules/UserMetrics/Metric.cpp:28
75+msgid "Failed to connect to metrics service:"
76+msgstr ""
77+
78+#: src/modules/UserMetrics/Metric.cpp:102
79+msgid "Failed to register user metric:"
80+msgstr ""
81+
82+#: src/modules/UserMetrics/Metric.cpp:115
83+msgid "Failed to increment metric:"
84+msgstr ""
85+
86+#: src/modules/UserMetrics/Metric.cpp:127
87+msgid "Failed to update metric:"
88+msgstr ""
89+
90 #: src/libusermetricsinput/main-increment.cpp:35
91 #: src/libusermetricsinput/main.cpp:35
92 msgid "Usage: "
93
94=== modified file 'src/modules/UserMetrics/Metric.cpp'
95--- src/modules/UserMetrics/Metric.cpp 2013-09-24 08:13:01 +0000
96+++ src/modules/UserMetrics/Metric.cpp 2013-09-26 15:27:09 +0000
97@@ -15,13 +15,18 @@
98 */
99
100 #include <modules/UserMetrics/Metric.h>
101+#include <libusermetricscommon/Localisation.h>
102
103+#include <stdexcept>
104 #include <QDebug>
105
106 Metric::Metric(QObject *parent) :
107- QObject(parent), m_metricManager(
108- UserMetricsInput::MetricManager::getInstance()), m_componentComplete(
109- false) {
110+ QObject(parent), m_componentComplete(false) {
111+ try {
112+ m_metricManager.reset(UserMetricsInput::MetricManager::getInstance());
113+ } catch (std::exception &e) {
114+ qWarning() << _("Failed to connect to metrics service:") << e.what();
115+ }
116 }
117
118 Metric::~Metric() {
119@@ -88,27 +93,38 @@
120 return;
121 }
122
123- m_metric =
124- m_metricManager->add(
125- UserMetricsInput::MetricParameters(m_name).formatString(
126- m_format).emptyDataString(m_emptyFormat).textDomain(
127- m_domain));
128-
129- if (m_metric.isNull()) {
130- qWarning() << "Failed to register user metric:" << m_name << "\""
131- << m_format << "\"";
132+ try {
133+ m_metric = m_metricManager->add(
134+ UserMetricsInput::MetricParameters(m_name).formatString(
135+ m_format).emptyDataString(m_emptyFormat).textDomain(
136+ m_domain));
137+ } catch (std::exception &e) {
138+ qWarning() << _("Failed to register user metric:") << m_name << "\""
139+ << m_format << "\": " << e.what();
140 }
141 }
142
143 void Metric::increment(double amount) {
144- if (!m_metric.isNull()) {
145+ if (m_metric.isNull()) {
146+ return;
147+ }
148+
149+ try {
150 m_metric->increment(amount);
151+ } catch (std::exception &e) {
152+ qWarning() << _("Failed to increment metric:") << e.what();
153 }
154 }
155
156 void Metric::update(double value) {
157- if (!m_metric.isNull()) {
158+ if (m_metric.isNull()) {
159+ return;
160+ }
161+
162+ try {
163 m_metric->update(value);
164+ } catch (std::exception &e) {
165+ qWarning() << _("Failed to update metric:") << e.what();
166 }
167 }
168

Subscribers

People subscribed via source and target branches

to all changes: