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
1=== modified file 'demo/provider_test/provider-test.cpp'
2--- demo/provider_test/provider-test.cpp 2016-08-11 07:06:35 +0000
3+++ demo/provider_test/provider-test.cpp 2016-08-12 01:35:56 +0000
4@@ -153,11 +153,13 @@
5 printf("list('%s', '%s') called by %s (%d)\n", item_id.c_str(), page_token.c_str(), ctx.security_label.c_str(), ctx.pid);
6 if (item_id != "root_id")
7 {
8- return make_exceptional_future<tuple<ItemList,string>>(runtime_error("unknown folder"));
9+ string msg = string("Item::list(): no such item: \"") + item_id + "\"";
10+ return make_exceptional_future<tuple<ItemList,string>>(NotExistsException(msg, item_id));
11 }
12 if (page_token != "")
13 {
14- return make_exceptional_future<tuple<ItemList,string>>(runtime_error("unknown page token"));
15+ string msg = string("Item::list(): invalid page token: \"") + page_token + "\"";
16+ return make_exceptional_future<tuple<ItemList,string>>(msg);
17 }
18 ItemList children =
19 {
20@@ -175,9 +177,15 @@
21 string const& parent_id, string const& name, Context const& ctx)
22 {
23 printf("lookup('%s', '%s') called by %s (%d)\n", parent_id.c_str(), name.c_str(), ctx.security_label.c_str(), ctx.pid);
24- if (parent_id != "root_id" || name != "Child")
25- {
26- return make_exceptional_future<ItemList>(runtime_error("file not found"));
27+ if (parent_id != "root_id")
28+ {
29+ string msg = string("Folder::lookup(): no such item: \"") + parent_id + "\"";
30+ return make_exceptional_future<ItemList>(NotExistsException(msg, parent_id));
31+ }
32+ if (name != "Child")
33+ {
34+ string msg = string("Folder::lookup(): no such item: \"") + name + "\"";
35+ return make_exceptional_future<ItemList>(NotExistsException(msg, name));
36 }
37 ItemList children =
38 {
39
40=== modified file 'src/provider/CMakeLists.txt'
41--- src/provider/CMakeLists.txt 2016-08-11 08:21:23 +0000
42+++ src/provider/CMakeLists.txt 2016-08-12 01:35:56 +0000
43@@ -78,6 +78,7 @@
44 target_compile_options(storage-framework-provider PUBLIC
45 $<TARGET_PROPERTY:sf-provider-objects,COMPILE_OPTIONS>)
46 target_link_libraries(storage-framework-provider
47+ storage-framework-common-internal
48 Qt5::Core
49 Qt5::DBus
50 Qt5::Network
51@@ -102,6 +103,7 @@
52 target_compile_options(storage-framework-provider-static PUBLIC
53 $<TARGET_PROPERTY:sf-provider-objects,COMPILE_OPTIONS>)
54 target_link_libraries(storage-framework-provider-static
55+ storage-framework-common-internal
56 Qt5::Core
57 Qt5::DBus
58 Qt5::Network
59
60=== modified file 'src/provider/internal/DownloadJobImpl.cpp'
61--- src/provider/internal/DownloadJobImpl.cpp 2016-08-09 06:19:48 +0000
62+++ src/provider/internal/DownloadJobImpl.cpp 2016-08-12 01:35:56 +0000
63@@ -17,7 +17,9 @@
64 */
65
66 #include <unity/storage/provider/internal/DownloadJobImpl.h>
67+#include <unity/storage/internal/safe_strerror.h>
68 #include <unity/storage/provider/DownloadJob.h>
69+#include <unity/storage/provider/Exceptions.h>
70
71 #include <sys/socket.h>
72 #include <sys/types.h>
73@@ -26,6 +28,7 @@
74 #include <stdexcept>
75
76 using namespace std;
77+using namespace unity::storage::internal;
78
79 namespace unity
80 {
81@@ -42,17 +45,23 @@
82 int socks[2];
83 if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) < 0)
84 {
85- throw runtime_error("could not create socketpair");
86+ int error_code = errno;
87+ string msg = "could not create socketpair: " + safe_strerror(error_code);
88+ throw ResourceException(msg, error_code);
89 }
90 read_socket_ = socks[0];
91 write_socket_ = socks[1];
92 if (shutdown(read_socket_, SHUT_WR) < 0)
93 {
94- throw runtime_error("Could not shut down write channel on read socket");
95+ int error_code = errno;
96+ string msg = "Could not shut down write channel on read socket" + safe_strerror(error_code);
97+ throw ResourceException(msg, error_code);
98 }
99 if (shutdown(write_socket_, SHUT_RD) < 0)
100 {
101- throw runtime_error("Could not shut down read channel on write socket");
102+ int error_code = errno;
103+ string msg = "Could not shut down read channel on write socket: " + safe_strerror(error_code);
104+ throw ResourceException(msg, error_code);
105 }
106 }
107
108@@ -129,6 +138,10 @@
109 {
110 std::rethrow_exception(p);
111 }
112+ catch (StorageException const& e)
113+ {
114+ completion_promise_.set_exception(e);
115+ }
116 catch (...)
117 {
118 completion_promise_.set_exception(boost::current_exception());
119
120=== modified file 'src/provider/internal/ProviderInterface.cpp'
121--- src/provider/internal/ProviderInterface.cpp 2016-07-21 12:48:40 +0000
122+++ src/provider/internal/ProviderInterface.cpp 2016-08-12 01:35:56 +0000
123@@ -18,6 +18,7 @@
124
125 #include <unity/storage/provider/internal/ProviderInterface.h>
126 #include <unity/storage/provider/DownloadJob.h>
127+#include <unity/storage/provider/Exceptions.h>
128 #include <unity/storage/provider/ProviderBase.h>
129 #include <unity/storage/provider/UploadJob.h>
130 #include <unity/storage/provider/internal/AccountData.h>
131@@ -223,7 +224,7 @@
132 auto job = account->jobs().get_upload(upload_id.toStdString());
133 if (job->p_->sender_bus_name() != message.service().toStdString())
134 {
135- throw runtime_error("Upload job belongs to a different client");
136+ throw LogicException("Upload job belongs to a different client");
137 }
138 // FIXME: removing the job at this point means we can't
139 // cancel during finish().
140@@ -246,7 +247,7 @@
141 auto job = account->jobs().get_upload(upload_id.toStdString());
142 if (job->p_->sender_bus_name() != message.service().toStdString())
143 {
144- throw runtime_error("Upload job belongs to a different client");
145+ throw LogicException("Upload job belongs to a different client");
146 }
147 account->jobs().remove_upload(upload_id.toStdString());
148 auto f = job->p_->cancel(*job);
149@@ -293,7 +294,7 @@
150 auto job = account->jobs().get_download(download_id.toStdString());
151 if (job->p_->sender_bus_name() != message.service().toStdString())
152 {
153- throw runtime_error("Download job belongs to a different client");
154+ throw LogicException("Download job belongs to a different client");
155 }
156 // FIXME: removing the job at this point means we can't
157 // cancel during finish().
158
159=== modified file 'src/provider/internal/ServerImpl.cpp'
160--- src/provider/internal/ServerImpl.cpp 2016-07-21 04:00:29 +0000
161+++ src/provider/internal/ServerImpl.cpp 2016-08-12 01:35:56 +0000
162@@ -17,6 +17,7 @@
163 */
164
165 #include <unity/storage/provider/internal/ServerImpl.h>
166+#include <unity/storage/provider/Exceptions.h>
167 #include <unity/storage/provider/ProviderBase.h>
168 #include <unity/storage/provider/internal/AccountData.h>
169 #include <unity/storage/provider/internal/MainLoopExecutor.h>
170@@ -85,7 +86,8 @@
171
172 if (!bus.registerService(QString::fromStdString(bus_name_)))
173 {
174- throw runtime_error("Could not acquire bus name: " + bus_name_);
175+ string msg = string("Could not acquire bus name: ") + bus_name_ + ": " + bus.lastError().message().toStdString();
176+ throw ResourceException(msg, int(bus.lastError().type()));
177 }
178 // TODO: claim bus name
179 qDebug() << "Bus unique name:" << bus.baseService();
180
181=== modified file 'src/provider/internal/TestServerImpl.cpp'
182--- src/provider/internal/TestServerImpl.cpp 2016-08-11 04:29:36 +0000
183+++ src/provider/internal/TestServerImpl.cpp 2016-08-12 01:35:56 +0000
184@@ -17,6 +17,7 @@
185 */
186
187 #include <unity/storage/provider/internal/TestServerImpl.h>
188+#include <unity/storage/provider/Exceptions.h>
189 #include <unity/storage/provider/ProviderBase.h>
190 #include <unity/storage/provider/internal/AccountData.h>
191 #include <unity/storage/provider/internal/DBusPeerCache.h>
192@@ -57,7 +58,8 @@
193 if (!connection_.registerObject(QString::fromStdString(object_path_),
194 interface_.get()))
195 {
196- throw runtime_error("Could not register provider on connection");
197+ string msg = "Could not register provider on connection: " + connection_.lastError().message().toStdString();
198+ throw ResourceException(msg, int(connection_.lastError().type()));
199 }
200 }
201
202
203=== modified file 'src/provider/internal/UploadJobImpl.cpp'
204--- src/provider/internal/UploadJobImpl.cpp 2016-08-09 06:19:48 +0000
205+++ src/provider/internal/UploadJobImpl.cpp 2016-08-12 01:35:56 +0000
206@@ -17,6 +17,8 @@
207 */
208
209 #include <unity/storage/provider/internal/UploadJobImpl.h>
210+#include <unity/storage/internal/safe_strerror.h>
211+#include <unity/storage/provider/Exceptions.h>
212 #include <unity/storage/provider/UploadJob.h>
213
214 #include <sys/socket.h>
215@@ -26,6 +28,7 @@
216 #include <stdexcept>
217
218 using namespace std;
219+using namespace unity::storage::internal;
220
221 namespace unity
222 {
223@@ -42,17 +45,23 @@
224 int socks[2];
225 if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks) < 0)
226 {
227- throw runtime_error("could not create socketpair");
228+ int error_code = errno;
229+ string msg = "could not create socketpair: " + safe_strerror(error_code);
230+ throw ResourceException(msg, error_code);
231 }
232 read_socket_ = socks[0];
233 write_socket_ = socks[1];
234 if (shutdown(read_socket_, SHUT_WR) < 0)
235 {
236- throw runtime_error("Could not shut down write channel on read socket");
237+ int error_code = errno;
238+ string msg = "could not shut down write channel on read socket: " + safe_strerror(error_code);
239+ throw ResourceException(msg, error_code);
240 }
241 if (shutdown(write_socket_, SHUT_RD) < 0)
242 {
243- throw runtime_error("Could not shut down read channel on write socket");
244+ int error_code = errno;
245+ string msg = "Could not shut down read channel on write socket" + safe_strerror(error_code);
246+ throw ResourceException(msg, error_code);
247 }
248 }
249
250@@ -116,6 +125,10 @@
251 {
252 std::rethrow_exception(p);
253 }
254+ catch (StorageException const& e)
255+ {
256+ completion_promise_.set_exception(e);
257+ }
258 catch (...)
259 {
260 completion_promise_.set_exception(boost::current_exception());
261
262=== modified file 'src/provider/internal/dbusmarshal.cpp'
263--- src/provider/internal/dbusmarshal.cpp 2016-08-09 07:04:11 +0000
264+++ src/provider/internal/dbusmarshal.cpp 2016-08-12 01:35:56 +0000
265@@ -80,7 +80,8 @@
266
267 QDBusArgument const& operator>>(QDBusArgument const&, Item&)
268 {
269- throw std::runtime_error("Item decode not implemented");
270+ // We don't expect to ever have to unmarshal anything, only marshal it.
271+ qFatal("unexpected call to operator>>(QDBusArgument const&, Item&)"); // LCOV_EXCL_LINE
272 }
273
274 QDBusArgument& operator<<(QDBusArgument& argument, ItemList const& items)
275@@ -96,7 +97,8 @@
276
277 QDBusArgument const& operator>>(QDBusArgument const&, ItemList&)
278 {
279- throw std::runtime_error("std::vector<Item> decode not implemented");
280+ // We don't expect to ever have to unmarshal anything, only marshal it.
281+ qFatal("unexpected call to operator>>(QDBusArgument const&, ItemList&)"); // LCOV_EXCL_LINE
282 }
283
284 }
285
286=== modified file 'tests/provider-ProviderInterface/ProviderInterface_test.cpp'
287--- tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-11 12:22:30 +0000
288+++ tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-12 01:35:56 +0000
289@@ -159,13 +159,13 @@
290 reply = client_->List("root_id", "bad_page_token");
291 wait_for(reply);
292 EXPECT_TRUE(reply.isError());
293- EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name()) << reply.error().name().toStdString();
294+ EXPECT_EQ(PROVIDER_ERROR + "LogicException", reply.error().name()) << reply.error().name().toStdString();
295 EXPECT_EQ("Unknown page token", reply.error().message()) << reply.error().message().toStdString();
296
297 reply = client_->List("no_such_folder_id", "");
298 wait_for(reply);
299 EXPECT_TRUE(reply.isError());
300- EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());
301+ EXPECT_EQ(PROVIDER_ERROR + "NotExistsException", reply.error().name());
302 EXPECT_EQ("Unknown folder", reply.error().message());
303 }
304
305@@ -323,7 +323,7 @@
306 auto reply = client_->FinishUpload(upload_id);
307 wait_for(reply);
308 ASSERT_TRUE(reply.isError());
309- EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());
310+ EXPECT_EQ(PROVIDER_ERROR + "LogicException", reply.error().name());
311 EXPECT_EQ("wrong number of bytes written", reply.error().message());
312 }
313
314@@ -460,7 +460,7 @@
315 auto reply = client_->FinishDownload(download_id);
316 wait_for(reply);
317 ASSERT_TRUE(reply.isError());
318- EXPECT_EQ(PROVIDER_ERROR + "UnknownException", reply.error().name());
319+ EXPECT_EQ(PROVIDER_ERROR + "LogicException", reply.error().name());
320 EXPECT_EQ("Not all data read", reply.error().message());
321 }
322
323
324=== modified file 'tests/provider-ProviderInterface/TestProvider.cpp'
325--- tests/provider-ProviderInterface/TestProvider.cpp 2016-08-11 04:37:13 +0000
326+++ tests/provider-ProviderInterface/TestProvider.cpp 2016-08-12 01:35:56 +0000
327@@ -17,6 +17,7 @@
328 */
329
330 #include "TestProvider.h"
331+#include <unity/storage/internal/safe_strerror.h>
332 #include <unity/storage/provider/DownloadJob.h>
333 #include <unity/storage/provider/Exceptions.h>
334 #include <unity/storage/provider/UploadJob.h>
335@@ -29,6 +30,8 @@
336
337 using namespace std;
338 using namespace unity::storage;
339+using namespace unity::storage::internal;
340+using namespace unity::storage::provider;
341
342 class TestUploadJob : public UploadJob
343 {
344@@ -75,7 +78,7 @@
345 }
346 else
347 {
348- p.set_exception(runtime_error("wrong number of bytes written"));
349+ p.set_exception(LogicException("wrong number of bytes written"));
350 }
351 return p.get_future();
352 }
353@@ -88,14 +91,15 @@
354 ssize_t n_read = read(read_socket(), buf, sizeof(buf));
355 if (n_read < 0)
356 {
357- report_error(make_exception_ptr(runtime_error("Read failure")));
358+ int error_code = errno;
359+ report_error(make_exception_ptr(ResourceException("Read failure: " + safe_strerror(error_code), error_code)));
360 notifier_.setEnabled(false);
361 }
362 else if (n_read == 0)
363 {
364 if (bytes_read_ != size_)
365 {
366- report_error(make_exception_ptr(runtime_error("wrong number of bytes")));
367+ report_error(make_exception_ptr(LogicException("wrong number of bytes")));
368 }
369 notifier_.setEnabled(false);
370 }
371@@ -105,7 +109,7 @@
372 if (bytes_read_ > size_)
373 {
374 printf("Reporting error\n");
375- report_error(make_exception_ptr(runtime_error("too many bytes written")));
376+ report_error(make_exception_ptr(LogicException("too many bytes written")));
377 notifier_.setEnabled(false);
378 }
379 }
380@@ -148,7 +152,7 @@
381 boost::promise<void> p;
382 if (bytes_written_ < (ssize_t)data_.size())
383 {
384- p.set_exception(runtime_error("Not all data read"));
385+ p.set_exception(LogicException("Not all data read"));
386 }
387 else
388 {
389@@ -169,7 +173,9 @@
390 min(data_.size() - bytes_written_, (size_t)2));
391 if (n_written < 0)
392 {
393- report_error(make_exception_ptr(runtime_error("Write failure")));
394+ int error_code = errno;
395+ string msg = string("Write failure: ") + safe_strerror(error_code);
396+ report_error(make_exception_ptr(ResourceException(msg, error_code)));
397 timer_.stop();
398 }
399 else
400@@ -200,7 +206,7 @@
401
402 if (item_id != "root_id")
403 {
404- p.set_exception(runtime_error("Unknown folder"));
405+ p.set_exception(NotExistsException("Unknown folder", item_id));
406 }
407 else if (page_token == "")
408 {
409@@ -220,7 +226,7 @@
410 }
411 else
412 {
413- p.set_exception(runtime_error("Unknown page token"));
414+ p.set_exception(LogicException("Unknown page token"));
415 }
416 return p.get_future();
417 }
418@@ -251,7 +257,7 @@
419 }
420 else
421 {
422- p.set_exception(runtime_error("Unknown item"));
423+ p.set_exception(NotExistsException("Unknown item", item_id));
424 }
425 return p.get_future();
426 }
427@@ -320,7 +326,7 @@
428 }
429 else
430 {
431- p.set_exception(runtime_error("Bad filename"));
432+ p.set_exception(NotExistsException("Bad filename", item_id));
433 }
434 return p.get_future();
435 }

Subscribers

People subscribed via source and target branches

to all changes: