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