Merge lp:~michihenning/storage-framework/provider-exceptions into lp:storage-framework/devel

Proposed by Michi Henning
Status: Merged
Approved by: James Henstridge
Approved revision: 52
Merged at revision: 53
Proposed branch: lp:~michihenning/storage-framework/provider-exceptions
Merge into: lp:storage-framework/devel
Diff against target: 435 lines (+81/-32)
10 files modified
demo/provider_test/provider-test.cpp (+13/-5)
src/provider/CMakeLists.txt (+2/-0)
src/provider/internal/DownloadJobImpl.cpp (+16/-3)
src/provider/internal/ProviderInterface.cpp (+4/-3)
src/provider/internal/ServerImpl.cpp (+3/-1)
src/provider/internal/TestServerImpl.cpp (+3/-1)
src/provider/internal/UploadJobImpl.cpp (+16/-3)
src/provider/internal/dbusmarshal.cpp (+4/-2)
tests/provider-ProviderInterface/ProviderInterface_test.cpp (+4/-4)
tests/provider-ProviderInterface/TestProvider.cpp (+16/-10)
To merge this branch: bzr merge lp:~michihenning/storage-framework/provider-exceptions
Reviewer Review Type Date Requested Status
James Henstridge Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+302737@code.launchpad.net

Commit message

Replaced runtime_error with storage exceptions on server side.

Description of the change

Replaced runtime_error with storage exceptions on server side.

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:52
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/74/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/371/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/377
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/294
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/294
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/294
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/224/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/224/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/224/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/224/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/224/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/224/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/224/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/224
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/224/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/224/console

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

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

PASSED: Continuous integration, rev:52
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/75/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/372
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/378
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/295
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/295
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/295
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/225/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/225
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/225/artifact/output/*zip*/output.zip

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

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

Looks great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'demo/provider_test/provider-test.cpp'
--- demo/provider_test/provider-test.cpp 2016-08-11 07:06:35 +0000
+++ demo/provider_test/provider-test.cpp 2016-08-12 01:35:56 +0000
@@ -153,11 +153,13 @@
153 printf("list('%s', '%s') called by %s (%d)\n", item_id.c_str(), page_token.c_str(), ctx.security_label.c_str(), ctx.pid);153 printf("list('%s', '%s') called by %s (%d)\n", item_id.c_str(), page_token.c_str(), ctx.security_label.c_str(), ctx.pid);
154 if (item_id != "root_id")154 if (item_id != "root_id")
155 {155 {
156 return make_exceptional_future<tuple<ItemList,string>>(runtime_error("unknown folder"));156 string msg = string("Item::list(): no such item: \"") + item_id + "\"";
157 return make_exceptional_future<tuple<ItemList,string>>(NotExistsException(msg, item_id));
157 }158 }
158 if (page_token != "")159 if (page_token != "")
159 {160 {
160 return make_exceptional_future<tuple<ItemList,string>>(runtime_error("unknown page token"));161 string msg = string("Item::list(): invalid page token: \"") + page_token + "\"";
162 return make_exceptional_future<tuple<ItemList,string>>(msg);
161 }163 }
162 ItemList children =164 ItemList children =
163 {165 {
@@ -175,9 +177,15 @@
175 string const& parent_id, string const& name, Context const& ctx)177 string const& parent_id, string const& name, Context const& ctx)
176{178{
177 printf("lookup('%s', '%s') called by %s (%d)\n", parent_id.c_str(), name.c_str(), ctx.security_label.c_str(), ctx.pid);179 printf("lookup('%s', '%s') called by %s (%d)\n", parent_id.c_str(), name.c_str(), ctx.security_label.c_str(), ctx.pid);
178 if (parent_id != "root_id" || name != "Child")180 if (parent_id != "root_id")
179 {181 {
180 return make_exceptional_future<ItemList>(runtime_error("file not found"));182 string msg = string("Folder::lookup(): no such item: \"") + parent_id + "\"";
183 return make_exceptional_future<ItemList>(NotExistsException(msg, parent_id));
184 }
185 if (name != "Child")
186 {
187 string msg = string("Folder::lookup(): no such item: \"") + name + "\"";
188 return make_exceptional_future<ItemList>(NotExistsException(msg, name));
181 }189 }
182 ItemList children =190 ItemList children =
183 {191 {
184192
=== modified file 'src/provider/CMakeLists.txt'
--- src/provider/CMakeLists.txt 2016-08-11 08:21:23 +0000
+++ src/provider/CMakeLists.txt 2016-08-12 01:35:56 +0000
@@ -78,6 +78,7 @@
78target_compile_options(storage-framework-provider PUBLIC78target_compile_options(storage-framework-provider PUBLIC
79 $<TARGET_PROPERTY:sf-provider-objects,COMPILE_OPTIONS>)79 $<TARGET_PROPERTY:sf-provider-objects,COMPILE_OPTIONS>)
80target_link_libraries(storage-framework-provider80target_link_libraries(storage-framework-provider
81 storage-framework-common-internal
81 Qt5::Core82 Qt5::Core
82 Qt5::DBus83 Qt5::DBus
83 Qt5::Network84 Qt5::Network
@@ -102,6 +103,7 @@
102target_compile_options(storage-framework-provider-static PUBLIC103target_compile_options(storage-framework-provider-static PUBLIC
103 $<TARGET_PROPERTY:sf-provider-objects,COMPILE_OPTIONS>)104 $<TARGET_PROPERTY:sf-provider-objects,COMPILE_OPTIONS>)
104target_link_libraries(storage-framework-provider-static105target_link_libraries(storage-framework-provider-static
106 storage-framework-common-internal
105 Qt5::Core107 Qt5::Core
106 Qt5::DBus108 Qt5::DBus
107 Qt5::Network109 Qt5::Network
108110
=== modified file 'src/provider/internal/DownloadJobImpl.cpp'
--- src/provider/internal/DownloadJobImpl.cpp 2016-08-09 06:19:48 +0000
+++ src/provider/internal/DownloadJobImpl.cpp 2016-08-12 01:35:56 +0000
@@ -17,7 +17,9 @@
17 */17 */
1818
19#include <unity/storage/provider/internal/DownloadJobImpl.h>19#include <unity/storage/provider/internal/DownloadJobImpl.h>
20#include <unity/storage/internal/safe_strerror.h>
20#include <unity/storage/provider/DownloadJob.h>21#include <unity/storage/provider/DownloadJob.h>
22#include <unity/storage/provider/Exceptions.h>
2123
22#include <sys/socket.h>24#include <sys/socket.h>
23#include <sys/types.h>25#include <sys/types.h>
@@ -26,6 +28,7 @@
26#include <stdexcept>28#include <stdexcept>
2729
28using namespace std;30using namespace std;
31using namespace unity::storage::internal;
2932
30namespace unity33namespace unity
31{34{
@@ -42,17 +45,23 @@
42 int socks[2];45 int socks[2];
43 if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) < 0)46 if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) < 0)
44 {47 {
45 throw runtime_error("could not create socketpair");48 int error_code = errno;
49 string msg = "could not create socketpair: " + safe_strerror(error_code);
50 throw ResourceException(msg, error_code);
46 }51 }
47 read_socket_ = socks[0];52 read_socket_ = socks[0];
48 write_socket_ = socks[1];53 write_socket_ = socks[1];
49 if (shutdown(read_socket_, SHUT_WR) < 0)54 if (shutdown(read_socket_, SHUT_WR) < 0)
50 {55 {
51 throw runtime_error("Could not shut down write channel on read socket");56 int error_code = errno;
57 string msg = "Could not shut down write channel on read socket" + safe_strerror(error_code);
58 throw ResourceException(msg, error_code);
52 }59 }
53 if (shutdown(write_socket_, SHUT_RD) < 0)60 if (shutdown(write_socket_, SHUT_RD) < 0)
54 {61 {
55 throw runtime_error("Could not shut down read channel on write socket");62 int error_code = errno;
63 string msg = "Could not shut down read channel on write socket: " + safe_strerror(error_code);
64 throw ResourceException(msg, error_code);
56 }65 }
57}66}
5867
@@ -129,6 +138,10 @@
129 {138 {
130 std::rethrow_exception(p);139 std::rethrow_exception(p);
131 }140 }
141 catch (StorageException const& e)
142 {
143 completion_promise_.set_exception(e);
144 }
132 catch (...)145 catch (...)
133 {146 {
134 completion_promise_.set_exception(boost::current_exception());147 completion_promise_.set_exception(boost::current_exception());
135148
=== modified file 'src/provider/internal/ProviderInterface.cpp'
--- src/provider/internal/ProviderInterface.cpp 2016-07-21 12:48:40 +0000
+++ src/provider/internal/ProviderInterface.cpp 2016-08-12 01:35:56 +0000
@@ -18,6 +18,7 @@
1818
19#include <unity/storage/provider/internal/ProviderInterface.h>19#include <unity/storage/provider/internal/ProviderInterface.h>
20#include <unity/storage/provider/DownloadJob.h>20#include <unity/storage/provider/DownloadJob.h>
21#include <unity/storage/provider/Exceptions.h>
21#include <unity/storage/provider/ProviderBase.h>22#include <unity/storage/provider/ProviderBase.h>
22#include <unity/storage/provider/UploadJob.h>23#include <unity/storage/provider/UploadJob.h>
23#include <unity/storage/provider/internal/AccountData.h>24#include <unity/storage/provider/internal/AccountData.h>
@@ -223,7 +224,7 @@
223 auto job = account->jobs().get_upload(upload_id.toStdString());224 auto job = account->jobs().get_upload(upload_id.toStdString());
224 if (job->p_->sender_bus_name() != message.service().toStdString())225 if (job->p_->sender_bus_name() != message.service().toStdString())
225 {226 {
226 throw runtime_error("Upload job belongs to a different client");227 throw LogicException("Upload job belongs to a different client");
227 }228 }
228 // FIXME: removing the job at this point means we can't229 // FIXME: removing the job at this point means we can't
229 // cancel during finish().230 // cancel during finish().
@@ -246,7 +247,7 @@
246 auto job = account->jobs().get_upload(upload_id.toStdString());247 auto job = account->jobs().get_upload(upload_id.toStdString());
247 if (job->p_->sender_bus_name() != message.service().toStdString())248 if (job->p_->sender_bus_name() != message.service().toStdString())
248 {249 {
249 throw runtime_error("Upload job belongs to a different client");250 throw LogicException("Upload job belongs to a different client");
250 }251 }
251 account->jobs().remove_upload(upload_id.toStdString());252 account->jobs().remove_upload(upload_id.toStdString());
252 auto f = job->p_->cancel(*job);253 auto f = job->p_->cancel(*job);
@@ -293,7 +294,7 @@
293 auto job = account->jobs().get_download(download_id.toStdString());294 auto job = account->jobs().get_download(download_id.toStdString());
294 if (job->p_->sender_bus_name() != message.service().toStdString())295 if (job->p_->sender_bus_name() != message.service().toStdString())
295 {296 {
296 throw runtime_error("Download job belongs to a different client");297 throw LogicException("Download job belongs to a different client");
297 }298 }
298 // FIXME: removing the job at this point means we can't299 // FIXME: removing the job at this point means we can't
299 // cancel during finish().300 // cancel during finish().
300301
=== modified file 'src/provider/internal/ServerImpl.cpp'
--- src/provider/internal/ServerImpl.cpp 2016-07-21 04:00:29 +0000
+++ src/provider/internal/ServerImpl.cpp 2016-08-12 01:35:56 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include <unity/storage/provider/internal/ServerImpl.h>19#include <unity/storage/provider/internal/ServerImpl.h>
20#include <unity/storage/provider/Exceptions.h>
20#include <unity/storage/provider/ProviderBase.h>21#include <unity/storage/provider/ProviderBase.h>
21#include <unity/storage/provider/internal/AccountData.h>22#include <unity/storage/provider/internal/AccountData.h>
22#include <unity/storage/provider/internal/MainLoopExecutor.h>23#include <unity/storage/provider/internal/MainLoopExecutor.h>
@@ -85,7 +86,8 @@
8586
86 if (!bus.registerService(QString::fromStdString(bus_name_)))87 if (!bus.registerService(QString::fromStdString(bus_name_)))
87 {88 {
88 throw runtime_error("Could not acquire bus name: " + bus_name_);89 string msg = string("Could not acquire bus name: ") + bus_name_ + ": " + bus.lastError().message().toStdString();
90 throw ResourceException(msg, int(bus.lastError().type()));
89 }91 }
90 // TODO: claim bus name92 // TODO: claim bus name
91 qDebug() << "Bus unique name:" << bus.baseService();93 qDebug() << "Bus unique name:" << bus.baseService();
9294
=== modified file 'src/provider/internal/TestServerImpl.cpp'
--- src/provider/internal/TestServerImpl.cpp 2016-08-11 04:29:36 +0000
+++ src/provider/internal/TestServerImpl.cpp 2016-08-12 01:35:56 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include <unity/storage/provider/internal/TestServerImpl.h>19#include <unity/storage/provider/internal/TestServerImpl.h>
20#include <unity/storage/provider/Exceptions.h>
20#include <unity/storage/provider/ProviderBase.h>21#include <unity/storage/provider/ProviderBase.h>
21#include <unity/storage/provider/internal/AccountData.h>22#include <unity/storage/provider/internal/AccountData.h>
22#include <unity/storage/provider/internal/DBusPeerCache.h>23#include <unity/storage/provider/internal/DBusPeerCache.h>
@@ -57,7 +58,8 @@
57 if (!connection_.registerObject(QString::fromStdString(object_path_),58 if (!connection_.registerObject(QString::fromStdString(object_path_),
58 interface_.get()))59 interface_.get()))
59 {60 {
60 throw runtime_error("Could not register provider on connection");61 string msg = "Could not register provider on connection: " + connection_.lastError().message().toStdString();
62 throw ResourceException(msg, int(connection_.lastError().type()));
61 }63 }
62}64}
6365
6466
=== modified file 'src/provider/internal/UploadJobImpl.cpp'
--- src/provider/internal/UploadJobImpl.cpp 2016-08-09 06:19:48 +0000
+++ src/provider/internal/UploadJobImpl.cpp 2016-08-12 01:35:56 +0000
@@ -17,6 +17,8 @@
17 */17 */
1818
19#include <unity/storage/provider/internal/UploadJobImpl.h>19#include <unity/storage/provider/internal/UploadJobImpl.h>
20#include <unity/storage/internal/safe_strerror.h>
21#include <unity/storage/provider/Exceptions.h>
20#include <unity/storage/provider/UploadJob.h>22#include <unity/storage/provider/UploadJob.h>
2123
22#include <sys/socket.h>24#include <sys/socket.h>
@@ -26,6 +28,7 @@
26#include <stdexcept>28#include <stdexcept>
2729
28using namespace std;30using namespace std;
31using namespace unity::storage::internal;
2932
30namespace unity33namespace unity
31{34{
@@ -42,17 +45,23 @@
42 int socks[2];45 int socks[2];
43 if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) < 0)46 if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) < 0)
44 {47 {
45 throw runtime_error("could not create socketpair");48 int error_code = errno;
49 string msg = "could not create socketpair: " + safe_strerror(error_code);
50 throw ResourceException(msg, error_code);
46 }51 }
47 read_socket_ = socks[0];52 read_socket_ = socks[0];
48 write_socket_ = socks[1];53 write_socket_ = socks[1];
49 if (shutdown(read_socket_, SHUT_WR) < 0)54 if (shutdown(read_socket_, SHUT_WR) < 0)
50 {55 {
51 throw runtime_error("Could not shut down write channel on read socket");56 int error_code = errno;
57 string msg = "could not shut down write channel on read socket: " + safe_strerror(error_code);
58 throw ResourceException(msg, error_code);
52 }59 }
53 if (shutdown(write_socket_, SHUT_RD) < 0)60 if (shutdown(write_socket_, SHUT_RD) < 0)
54 {61 {
55 throw runtime_error("Could not shut down read channel on write socket");62 int error_code = errno;
63 string msg = "Could not shut down read channel on write socket" + safe_strerror(error_code);
64 throw ResourceException(msg, error_code);
56 }65 }
57}66}
5867
@@ -116,6 +125,10 @@
116 {125 {
117 std::rethrow_exception(p);126 std::rethrow_exception(p);
118 }127 }
128 catch (StorageException const& e)
129 {
130 completion_promise_.set_exception(e);
131 }
119 catch (...)132 catch (...)
120 {133 {
121 completion_promise_.set_exception(boost::current_exception());134 completion_promise_.set_exception(boost::current_exception());
122135
=== modified file 'src/provider/internal/dbusmarshal.cpp'
--- src/provider/internal/dbusmarshal.cpp 2016-08-09 07:04:11 +0000
+++ src/provider/internal/dbusmarshal.cpp 2016-08-12 01:35:56 +0000
@@ -80,7 +80,8 @@
8080
81QDBusArgument const& operator>>(QDBusArgument const&, Item&)81QDBusArgument const& operator>>(QDBusArgument const&, Item&)
82{82{
83 throw std::runtime_error("Item decode not implemented");83 // We don't expect to ever have to unmarshal anything, only marshal it.
84 qFatal("unexpected call to operator>>(QDBusArgument const&, Item&)"); // LCOV_EXCL_LINE
84}85}
8586
86QDBusArgument& operator<<(QDBusArgument& argument, ItemList const& items)87QDBusArgument& operator<<(QDBusArgument& argument, ItemList const& items)
@@ -96,7 +97,8 @@
9697
97QDBusArgument const& operator>>(QDBusArgument const&, ItemList&)98QDBusArgument const& operator>>(QDBusArgument const&, ItemList&)
98{99{
99 throw std::runtime_error("std::vector<Item> decode not implemented");100 // We don't expect to ever have to unmarshal anything, only marshal it.
101 qFatal("unexpected call to operator>>(QDBusArgument const&, ItemList&)"); // LCOV_EXCL_LINE
100}102}
101103
102}104}
103105
=== modified file 'tests/provider-ProviderInterface/ProviderInterface_test.cpp'
--- tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-11 12:22:30 +0000
+++ tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-12 01:35:56 +0000
@@ -159,13 +159,13 @@
159 reply = client_->List("root_id", "bad_page_token");159 reply = client_->List("root_id", "bad_page_token");
160 wait_for(reply);160 wait_for(reply);
161 EXPECT_TRUE(reply.isError());161 EXPECT_TRUE(reply.isError());
162 EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name()) << reply.error().name().toStdString();162 EXPECT_EQ(PROVIDER_ERROR + "LogicException", reply.error().name()) << reply.error().name().toStdString();
163 EXPECT_EQ("Unknown page token", reply.error().message()) << reply.error().message().toStdString();163 EXPECT_EQ("Unknown page token", reply.error().message()) << reply.error().message().toStdString();
164164
165 reply = client_->List("no_such_folder_id", "");165 reply = client_->List("no_such_folder_id", "");
166 wait_for(reply);166 wait_for(reply);
167 EXPECT_TRUE(reply.isError());167 EXPECT_TRUE(reply.isError());
168 EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());168 EXPECT_EQ(PROVIDER_ERROR + "NotExistsException", reply.error().name());
169 EXPECT_EQ("Unknown folder", reply.error().message());169 EXPECT_EQ("Unknown folder", reply.error().message());
170}170}
171171
@@ -323,7 +323,7 @@
323 auto reply = client_->FinishUpload(upload_id);323 auto reply = client_->FinishUpload(upload_id);
324 wait_for(reply);324 wait_for(reply);
325 ASSERT_TRUE(reply.isError());325 ASSERT_TRUE(reply.isError());
326 EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());326 EXPECT_EQ(PROVIDER_ERROR + "LogicException", reply.error().name());
327 EXPECT_EQ("wrong number of bytes written", reply.error().message());327 EXPECT_EQ("wrong number of bytes written", reply.error().message());
328}328}
329329
@@ -460,7 +460,7 @@
460 auto reply = client_->FinishDownload(download_id);460 auto reply = client_->FinishDownload(download_id);
461 wait_for(reply);461 wait_for(reply);
462 ASSERT_TRUE(reply.isError());462 ASSERT_TRUE(reply.isError());
463 EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());463 EXPECT_EQ(PROVIDER_ERROR + "LogicException", reply.error().name());
464 EXPECT_EQ("Not all data read", reply.error().message());464 EXPECT_EQ("Not all data read", reply.error().message());
465}465}
466466
467467
=== modified file 'tests/provider-ProviderInterface/TestProvider.cpp'
--- tests/provider-ProviderInterface/TestProvider.cpp 2016-08-11 04:37:13 +0000
+++ tests/provider-ProviderInterface/TestProvider.cpp 2016-08-12 01:35:56 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "TestProvider.h"19#include "TestProvider.h"
20#include <unity/storage/internal/safe_strerror.h>
20#include <unity/storage/provider/DownloadJob.h>21#include <unity/storage/provider/DownloadJob.h>
21#include <unity/storage/provider/Exceptions.h>22#include <unity/storage/provider/Exceptions.h>
22#include <unity/storage/provider/UploadJob.h>23#include <unity/storage/provider/UploadJob.h>
@@ -29,6 +30,8 @@
2930
30using namespace std;31using namespace std;
31using namespace unity::storage;32using namespace unity::storage;
33using namespace unity::storage::internal;
34using namespace unity::storage::provider;
3235
33class TestUploadJob : public UploadJob36class TestUploadJob : public UploadJob
34{37{
@@ -75,7 +78,7 @@
75 }78 }
76 else79 else
77 {80 {
78 p.set_exception(runtime_error("wrong number of bytes written"));81 p.set_exception(LogicException("wrong number of bytes written"));
79 }82 }
80 return p.get_future();83 return p.get_future();
81}84}
@@ -88,14 +91,15 @@
88 ssize_t n_read = read(read_socket(), buf, sizeof(buf));91 ssize_t n_read = read(read_socket(), buf, sizeof(buf));
89 if (n_read < 0)92 if (n_read < 0)
90 {93 {
91 report_error(make_exception_ptr(runtime_error("Read failure")));94 int error_code = errno;
95 report_error(make_exception_ptr(ResourceException("Read failure: " + safe_strerror(error_code), error_code)));
92 notifier_.setEnabled(false);96 notifier_.setEnabled(false);
93 }97 }
94 else if (n_read == 0)98 else if (n_read == 0)
95 {99 {
96 if (bytes_read_ != size_)100 if (bytes_read_ != size_)
97 {101 {
98 report_error(make_exception_ptr(runtime_error("wrong number of bytes")));102 report_error(make_exception_ptr(LogicException("wrong number of bytes")));
99 }103 }
100 notifier_.setEnabled(false);104 notifier_.setEnabled(false);
101 }105 }
@@ -105,7 +109,7 @@
105 if (bytes_read_ > size_)109 if (bytes_read_ > size_)
106 {110 {
107 printf("Reporting error\n");111 printf("Reporting error\n");
108 report_error(make_exception_ptr(runtime_error("too many bytes written")));112 report_error(make_exception_ptr(LogicException("too many bytes written")));
109 notifier_.setEnabled(false);113 notifier_.setEnabled(false);
110 }114 }
111 }115 }
@@ -148,7 +152,7 @@
148 boost::promise<void> p;152 boost::promise<void> p;
149 if (bytes_written_ < (ssize_t)data_.size())153 if (bytes_written_ < (ssize_t)data_.size())
150 {154 {
151 p.set_exception(runtime_error("Not all data read"));155 p.set_exception(LogicException("Not all data read"));
152 }156 }
153 else157 else
154 {158 {
@@ -169,7 +173,9 @@
169 min(data_.size() - bytes_written_, (size_t)2));173 min(data_.size() - bytes_written_, (size_t)2));
170 if (n_written < 0)174 if (n_written < 0)
171 {175 {
172 report_error(make_exception_ptr(runtime_error("Write failure")));176 int error_code = errno;
177 string msg = string("Write failure: ") + safe_strerror(error_code);
178 report_error(make_exception_ptr(ResourceException(msg, error_code)));
173 timer_.stop();179 timer_.stop();
174 }180 }
175 else181 else
@@ -200,7 +206,7 @@
200206
201 if (item_id != "root_id")207 if (item_id != "root_id")
202 {208 {
203 p.set_exception(runtime_error("Unknown folder"));209 p.set_exception(NotExistsException("Unknown folder", item_id));
204 }210 }
205 else if (page_token == "")211 else if (page_token == "")
206 {212 {
@@ -220,7 +226,7 @@
220 }226 }
221 else227 else
222 {228 {
223 p.set_exception(runtime_error("Unknown page token"));229 p.set_exception(LogicException("Unknown page token"));
224 }230 }
225 return p.get_future();231 return p.get_future();
226}232}
@@ -251,7 +257,7 @@
251 }257 }
252 else258 else
253 {259 {
254 p.set_exception(runtime_error("Unknown item"));260 p.set_exception(NotExistsException("Unknown item", item_id));
255 }261 }
256 return p.get_future();262 return p.get_future();
257}263}
@@ -320,7 +326,7 @@
320 }326 }
321 else327 else
322 {328 {
323 p.set_exception(runtime_error("Bad filename"));329 p.set_exception(NotExistsException("Bad filename", item_id));
324 }330 }
325 return p.get_future();331 return p.get_future();
326}332}

Subscribers

People subscribed via source and target branches

to all changes: