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
=== modified file 'po/en_GB.po'
--- po/en_GB.po 2013-09-25 10:12:27 +0000
+++ po/en_GB.po 2013-09-26 15:27:09 +0000
@@ -2,12 +2,11 @@
2# This file is distributed under the same license as the libusermetrics package.2# This file is distributed under the same license as the libusermetrics package.
3# Pete Woods <pete.woods@canonical.com>, 2013.3# Pete Woods <pete.woods@canonical.com>, 2013.
4#4#
5#, fuzzy
6msgid ""5msgid ""
7msgstr ""6msgstr ""
8"Project-Id-Version: libusermetrics\n"7"Project-Id-Version: libusermetrics\n"
9"Report-Msgid-Bugs-To: \n"8"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2013-09-25 11:09+0100\n"9"POT-Creation-Date: 2013-09-26 16:22+0100\n"
11"PO-Revision-Date: 2013-07-05 15:09+0100\n"10"PO-Revision-Date: 2013-07-05 15:09+0100\n"
12"Last-Translator: Pete Woods <pete.woods@canonical.com>\n"11"Last-Translator: Pete Woods <pete.woods@canonical.com>\n"
13"Language-Team: British English <en@li.org>\n"12"Language-Team: British English <en@li.org>\n"
@@ -30,7 +29,6 @@
30msgstr "Attempt to create data source owned by another application"29msgstr "Attempt to create data source owned by another application"
3130
32#: src/usermetricsservice/DBusUserMetrics.cpp:24131#: src/usermetricsservice/DBusUserMetrics.cpp:241
33#, fuzzy
34msgid "Attempt to create user data owned by another user"32msgid "Attempt to create user data owned by another user"
35msgstr "Attempt to create user data owned by another user"33msgstr "Attempt to create user data owned by another user"
3634
@@ -85,7 +83,6 @@
85msgstr "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME <DATA>"83msgstr "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME <DATA>"
8684
87#: src/libusermetricsinput/main-increment.cpp:3785#: src/libusermetricsinput/main-increment.cpp:37
88#, fuzzy
89msgid "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME [AMOUNT]"86msgid "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME [AMOUNT]"
90msgstr "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME [AMOUNT]"87msgstr "DATA_SOURCE_ID FORMAT_STRING EMPTY_DATA_STRING USERNAME [AMOUNT]"
9188
@@ -101,6 +98,22 @@
101msgid "Data source query failed"98msgid "Data source query failed"
102msgstr "Data source query failed"99msgstr "Data source query failed"
103100
101#: src/modules/UserMetrics/Metric.cpp:28
102msgid "Failed to connect to metrics service:"
103msgstr "Failed to connect to metrics service:"
104
105#: src/modules/UserMetrics/Metric.cpp:115
106msgid "Failed to increment metric:"
107msgstr ""
108
109#: src/modules/UserMetrics/Metric.cpp:102
110msgid "Failed to register user metric:"
111msgstr "Failed to register user metric:"
112
113#: src/modules/UserMetrics/Metric.cpp:127
114msgid "Failed to update metric:"
115msgstr "Failed to update metric:"
116
104#: src/usermetricsservice/DBusUserData.cpp:132117#: src/usermetricsservice/DBusUserData.cpp:132
105msgid "New data set could not be found"118msgid "New data set could not be found"
106msgstr "New data set couldn't be found"119msgstr "New data set couldn't be found"
107120
=== modified file 'po/libusermetrics.pot'
--- po/libusermetrics.pot 2013-09-25 10:12:27 +0000
+++ po/libusermetrics.pot 2013-09-26 15:27:09 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: libusermetrics\n"9"Project-Id-Version: libusermetrics\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2013-09-25 11:09+0100\n"11"POT-Creation-Date: 2013-09-26 16:22+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -111,6 +111,22 @@
111msgid "New data set could not be found"111msgid "New data set could not be found"
112msgstr ""112msgstr ""
113113
114#: src/modules/UserMetrics/Metric.cpp:28
115msgid "Failed to connect to metrics service:"
116msgstr ""
117
118#: src/modules/UserMetrics/Metric.cpp:102
119msgid "Failed to register user metric:"
120msgstr ""
121
122#: src/modules/UserMetrics/Metric.cpp:115
123msgid "Failed to increment metric:"
124msgstr ""
125
126#: src/modules/UserMetrics/Metric.cpp:127
127msgid "Failed to update metric:"
128msgstr ""
129
114#: src/libusermetricsinput/main-increment.cpp:35130#: src/libusermetricsinput/main-increment.cpp:35
115#: src/libusermetricsinput/main.cpp:35131#: src/libusermetricsinput/main.cpp:35
116msgid "Usage: "132msgid "Usage: "
117133
=== modified file 'src/modules/UserMetrics/Metric.cpp'
--- src/modules/UserMetrics/Metric.cpp 2013-09-24 08:13:01 +0000
+++ src/modules/UserMetrics/Metric.cpp 2013-09-26 15:27:09 +0000
@@ -15,13 +15,18 @@
15 */15 */
1616
17#include <modules/UserMetrics/Metric.h>17#include <modules/UserMetrics/Metric.h>
18#include <libusermetricscommon/Localisation.h>
1819
20#include <stdexcept>
19#include <QDebug>21#include <QDebug>
2022
21Metric::Metric(QObject *parent) :23Metric::Metric(QObject *parent) :
22 QObject(parent), m_metricManager(24 QObject(parent), m_componentComplete(false) {
23 UserMetricsInput::MetricManager::getInstance()), m_componentComplete(25 try {
24 false) {26 m_metricManager.reset(UserMetricsInput::MetricManager::getInstance());
27 } catch (std::exception &e) {
28 qWarning() << _("Failed to connect to metrics service:") << e.what();
29 }
25}30}
2631
27Metric::~Metric() {32Metric::~Metric() {
@@ -88,27 +93,38 @@
88 return;93 return;
89 }94 }
9095
91 m_metric =96 try {
92 m_metricManager->add(97 m_metric = m_metricManager->add(
93 UserMetricsInput::MetricParameters(m_name).formatString(98 UserMetricsInput::MetricParameters(m_name).formatString(
94 m_format).emptyDataString(m_emptyFormat).textDomain(99 m_format).emptyDataString(m_emptyFormat).textDomain(
95 m_domain));100 m_domain));
96101 } catch (std::exception &e) {
97 if (m_metric.isNull()) {102 qWarning() << _("Failed to register user metric:") << m_name << "\""
98 qWarning() << "Failed to register user metric:" << m_name << "\""103 << m_format << "\": " << e.what();
99 << m_format << "\"";
100 }104 }
101}105}
102106
103void Metric::increment(double amount) {107void Metric::increment(double amount) {
104 if (!m_metric.isNull()) {108 if (m_metric.isNull()) {
109 return;
110 }
111
112 try {
105 m_metric->increment(amount);113 m_metric->increment(amount);
114 } catch (std::exception &e) {
115 qWarning() << _("Failed to increment metric:") << e.what();
106 }116 }
107}117}
108118
109void Metric::update(double value) {119void Metric::update(double value) {
110 if (!m_metric.isNull()) {120 if (m_metric.isNull()) {
121 return;
122 }
123
124 try {
111 m_metric->update(value);125 m_metric->update(value);
126 } catch (std::exception &e) {
127 qWarning() << _("Failed to update metric:") << e.what();
112 }128 }
113}129}
114130

Subscribers

People subscribed via source and target branches

to all changes: