Merge lp:~michihenning/unity-scopes-api/what-for-exceptions into lp:unity-scopes-api

Proposed by Michi Henning
Status: Merged
Approved by: James Henstridge
Approved revision: 91
Merged at revision: 94
Proposed branch: lp:~michihenning/unity-scopes-api/what-for-exceptions
Merge into: lp:unity-scopes-api
Diff against target: 472 lines (+37/-101)
11 files modified
include/scopes/ScopeExceptions.h (+1/-31)
src/ScopeExceptions.cpp (+6/-38)
src/internal/QueryObject.cpp (+3/-3)
src/internal/ReplyObject.cpp (+9/-3)
src/internal/RuntimeImpl.cpp (+4/-1)
src/internal/ScopeImpl.cpp (+4/-1)
src/internal/ScopeLoader.cpp (+3/-4)
src/internal/ScopeObject.cpp (+4/-1)
src/internal/zmq_middleware/ObjectAdapter.cpp (+0/-12)
src/internal/zmq_middleware/ServantBase.cpp (+0/-4)
test/gtest/scopes/ScopeExceptions/ScopeExceptions_test.cpp (+3/-3)
To merge this branch: bzr merge lp:~michihenning/unity-scopes-api/what-for-exceptions
Reviewer Review Type Date Requested Status
James Henstridge Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+198872@code.launchpad.net

Commit message

Made changes required by new API for exceptions in unity-api: https://code.launchpad.net/~michihenning/unity-api/what-fix/+merge/198871.

Description of the change

Made changes required by new API for exceptions in unity-api: https://code.launchpad.net/~michihenning/unity-api/what-fix/+merge/198871.

Note that merging this branch depends on https://code.launchpad.net/~michihenning/unity-api/what-fix/+merge/198871 being merged first. Because that branch is in a different project, it can't be made a dependent branch.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Need to kick Jenkins once the dependent branch is merged.

91. By Michi Henning

* Remove factory_configfile() API as well as the need to define it in
  the configuration files.
[ Michal Hruby ]
* Bump version because of the ResultItem rename.
[ Pawel Stolowski ]
* Added API for annotations.
* Added Result::metadata() getter. Create null Variant with default ctor.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good. Removing the extra catch clauses is a nice simplification too.

review: Approve
Revision history for this message
Michal Hruby (mhr3) wrote :

Please bump library version requirements as well as debian/control when adapting to API changes in underlying libraries next time.

Revision history for this message
Michi Henning (michihenning) wrote :

Ah, mea culpa. Thanks for the heads-up! Is it OK to leave as is now, or do I need to push another MR?

Revision history for this message
Michal Hruby (mhr3) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/scopes/ScopeExceptions.h'
2--- include/scopes/ScopeExceptions.h 2013-11-21 21:44:00 +0000
3+++ include/scopes/ScopeExceptions.h 2013-12-17 01:40:22 +0000
4@@ -30,11 +30,6 @@
5 namespace scopes
6 {
7
8-namespace internal
9-{
10-class MiddlewareExceptionImpl;
11-}
12-
13 /**
14 \brief Exception to indicate that something went wrong with the middleware layer.
15 */
16@@ -54,21 +49,11 @@
17 //! @endcond
18
19 /**
20- \brief Returns the fully-qualified name of the exception.
21- */
22- virtual char const* what() const noexcept override;
23-
24- /**
25 \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
26 */
27 virtual std::exception_ptr self() const override;
28 };
29
30-namespace internal
31-{
32-class ConfigExceptionImpl;
33-}
34-
35 /**
36 \brief Exception to indicate that something went wrong with the contents of configuration files.
37 */
38@@ -88,21 +73,11 @@
39 //! @endcond
40
41 /**
42- \brief Returns the fully-qualified name of the exception.
43- */
44- virtual char const* what() const noexcept override;
45-
46- /**
47 \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
48 */
49 virtual std::exception_ptr self() const override;
50 };
51
52-namespace internal
53-{
54-class NotFoundExceptionImpl;
55-}
56-
57 /**
58 \brief Exception to indicate that an object wasn't found by a lookup function.
59 */
60@@ -123,11 +98,6 @@
61 //! @endcond
62
63 /**
64- \brief Returns the fully-qualified name of the exception.
65- */
66- virtual char const* what() const noexcept override;
67-
68- /**
69 \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
70 */
71 virtual std::exception_ptr self() const override;
72@@ -138,7 +108,7 @@
73 virtual std::string name() const;
74
75 private:
76- std::shared_ptr<internal::NotFoundExceptionImpl> p;
77+ std::string name_;
78 };
79
80 } // namespace scopes
81
82=== modified file 'src/ScopeExceptions.cpp'
83--- src/ScopeExceptions.cpp 2013-11-21 21:44:00 +0000
84+++ src/ScopeExceptions.cpp 2013-12-17 01:40:22 +0000
85@@ -18,8 +18,6 @@
86
87 #include <scopes/ScopeExceptions.h>
88
89-#include <unity/ExceptionImplBase.h>
90-
91 using namespace std;
92
93 namespace unity
94@@ -32,7 +30,7 @@
95 {
96
97 MiddlewareException::MiddlewareException(string const& reason) :
98- Exception(make_shared<unity::ExceptionImplBase>(this, reason))
99+ Exception("unity::api::scopes::MiddlewareException", reason)
100 {
101 }
102
103@@ -47,18 +45,13 @@
104
105 //! @endcond
106
107-char const* MiddlewareException::what() const noexcept
108-{
109- return "unity::api::scopes::MiddlewareException";
110-}
111-
112 exception_ptr MiddlewareException::self() const
113 {
114 return make_exception_ptr(*this);
115 }
116
117 ConfigException::ConfigException(string const& reason) :
118- Exception(make_shared<unity::ExceptionImplBase>(this, reason))
119+ Exception("unity::api::scopes::ConfigException", reason)
120 {
121 }
122
123@@ -73,12 +66,6 @@
124
125 //! @endcond
126
127-char const*
128-ConfigException::what() const noexcept
129-{
130- return "unity::api::scopes::ConfigException";
131-}
132-
133 exception_ptr
134 ConfigException::
135 self() const
136@@ -86,24 +73,10 @@
137 return make_exception_ptr(*this);
138 }
139
140-namespace internal
141-{
142-
143-class NotFoundExceptionImpl : public unity::ExceptionImplBase
144-{
145-public:
146- NotFoundExceptionImpl(NotFoundException const* owner, string const& reason, string const& name) :
147- ExceptionImplBase(owner, reason + " (name = " + name + ")"),
148- name_(name)
149- {
150- }
151- string name_;
152-};
153-
154-} // namespace internal
155-
156 NotFoundException::NotFoundException(string const& reason, string const& name) :
157- Exception(make_shared<internal::NotFoundExceptionImpl>(this, reason, name))
158+ Exception("unity::api::scopes::NotFoundException",
159+ reason + (reason.empty() ? "" : " ") + "(name = " + name + ")"),
160+ name_(name)
161 {
162 }
163
164@@ -118,11 +91,6 @@
165
166 //! @endcond
167
168-char const* NotFoundException::what() const noexcept
169-{
170- return "unity::api::scopes::NotFoundException";
171-}
172-
173 exception_ptr NotFoundException::self() const
174 {
175 return make_exception_ptr(*this);
176@@ -130,7 +98,7 @@
177
178 string NotFoundException::name() const
179 {
180- return dynamic_cast<const internal::NotFoundExceptionImpl*>(pimpl())->name_;
181+ return name_;
182 }
183
184 } // namespace scopes
185
186=== modified file 'src/internal/QueryObject.cpp'
187--- src/internal/QueryObject.cpp 2013-12-11 16:20:02 +0000
188+++ src/internal/QueryObject.cpp 2013-12-17 01:40:22 +0000
189@@ -91,19 +91,19 @@
190 {
191 query_base_->run(reply_proxy);
192 }
193- catch (unity::Exception const& e)
194+ catch (std::exception const& e)
195 {
196 pushable_ = false;
197 reply_->finished(ReceiverBase::Error); // Oneway, can't block
198 // TODO: log error
199- cerr << "An error occurred in ScopeBase::run(): " << e.to_string() << endl;
200+ cerr << "ScopeBase::run(): " << e.what() << endl;
201 }
202 catch (...)
203 {
204 pushable_ = false;
205 reply_->finished(ReceiverBase::Error); // Oneway, can't block
206 // TODO: log error
207- cerr << "An unknown error occurred in ScopeBase::run()" << endl;
208+ cerr << "ScopeBase::run(): unknown exception" << endl;
209 }
210 }
211
212
213=== modified file 'src/internal/ReplyObject.cpp'
214--- src/internal/ReplyObject.cpp 2013-12-06 11:22:12 +0000
215+++ src/internal/ReplyObject.cpp 2013-12-17 01:40:22 +0000
216@@ -25,6 +25,7 @@
217 #include <unity/Exception.h>
218
219 #include <cassert>
220+#include <iostream> // TODO: remove this once logging is added
221
222 using namespace std;
223 using namespace unity::api::scopes::internal;
224@@ -125,16 +126,18 @@
225 CategorisedResult result(*cat_registry_, result_var);
226 receiver_base_->push(std::move(result));
227 }
228- catch (unity::Exception const& e)
229+ catch (std::exception const& e)
230 {
231 // TODO: this is an internal error; log error
232+ cerr << "ReplyObject::receiver_base_->push(): " << e.what() << endl;
233 finished(ReceiverBase::Error);
234 }
235 }
236 }
237- catch (unity::Exception const& e)
238+ catch (std::exception const& e)
239 {
240 // TODO: log error
241+ cerr << "ReplyObject::push(VariantMap): " << e.what() << endl;
242 try
243 {
244 finished(ReceiverBase::Error);
245@@ -146,6 +149,7 @@
246 catch (...)
247 {
248 // TODO: log error
249+ cerr << "ReplyObject::push(VariantMap): unknown exception" << endl;
250 try
251 {
252 finished(ReceiverBase::Error);
253@@ -186,12 +190,14 @@
254 {
255 receiver_base_->finished(r);
256 }
257- catch (unity::Exception const& e)
258+ catch (std::exception const& e)
259 {
260+ cerr << "ReplyObject::finished(): " << e.what() << endl;
261 // TODO: log error
262 }
263 catch (...)
264 {
265+ cerr << "ReplyObject::finished(): unknown exception" << endl;
266 // TODO: log error
267 }
268 }
269
270=== modified file 'src/internal/RuntimeImpl.cpp'
271--- src/internal/RuntimeImpl.cpp 2013-12-06 11:18:35 +0000
272+++ src/internal/RuntimeImpl.cpp 2013-12-17 01:40:22 +0000
273@@ -28,6 +28,7 @@
274
275 #include <cassert>
276 #include <future>
277+#include <iostream> // TODO: remove this once logging is added
278
279 #include <config.h>
280
281@@ -93,12 +94,14 @@
282 {
283 destroy();
284 }
285- catch (unity::Exception const& e) // LCOV_EXCL_LINE
286+ catch (std::exception const& e) // LCOV_EXCL_LINE
287 {
288+ cerr << "~RuntimeImpl(): " << e.what() << endl;
289 // TODO: log error
290 }
291 catch (...) // LCOV_EXCL_LINE
292 {
293+ cerr << "~RuntimeImpl(): unknown exception" << endl;
294 // TODO: log error
295 }
296 }
297
298=== modified file 'src/internal/ScopeImpl.cpp'
299--- src/internal/ScopeImpl.cpp 2013-11-26 04:27:32 +0000
300+++ src/internal/ScopeImpl.cpp 2013-12-17 01:40:22 +0000
301@@ -25,6 +25,7 @@
302 #include <unity/Exception.h>
303
304 #include <cassert>
305+#include <iostream> // TODO: remove this once logging is added
306
307 using namespace std;
308
309@@ -70,9 +71,10 @@
310 ctrl = fwd()->create_query(q, hints, rp);
311 assert(ctrl);
312 }
313- catch (unity::Exception const& e)
314+ catch (std::exception const& e)
315 {
316 // TODO: log error
317+ cerr << "create_query(): " << e.what() << endl;
318 try
319 {
320 // TODO: if things go wrong, we need to make sure that the reply object
321@@ -82,6 +84,7 @@
322 }
323 catch (...)
324 {
325+ cerr << "create_query(): unknown exception" << endl;
326 }
327 throw;
328 }
329
330=== modified file 'src/internal/ScopeLoader.cpp'
331--- src/internal/ScopeLoader.cpp 2013-11-25 19:05:41 +0000
332+++ src/internal/ScopeLoader.cpp 2013-12-17 01:40:22 +0000
333@@ -23,6 +23,7 @@
334 #include <unity/util/ResourcePtr.h>
335
336 #include <cassert>
337+#include <iostream> // TODO: remove this once logging is added
338
339 using namespace std;
340 using namespace unity::api::scopes;
341@@ -96,16 +97,14 @@
342 {
343 unload();
344 }
345- catch (unity::Exception const& e)
346- {
347- // TODO: log error
348- }
349 catch (std::exception const& e) // LCOV_EXCL_LINE
350 {
351+ cerr << "~ScopeLoader(): " << e.what() << endl;
352 // TODO: log error
353 }
354 catch (...) // LCOV_EXCL_LINE
355 {
356+ cerr << "~ScopeLoader(): unknown exception" << endl;
357 // TODO: log error
358 }
359 }
360
361=== modified file 'src/internal/ScopeObject.cpp'
362--- src/internal/ScopeObject.cpp 2013-11-25 19:05:41 +0000
363+++ src/internal/ScopeObject.cpp 2013-12-17 01:40:22 +0000
364@@ -28,6 +28,7 @@
365 #include <unity/UnityExceptions.h>
366
367 #include <cassert>
368+#include <iostream> // TODO: remove this once logging is added
369 #include <sstream>
370
371 using namespace std;
372@@ -118,7 +119,7 @@
373
374 query_proxy->run(reply);
375 }
376- catch (unity::Exception const& e)
377+ catch (std::exception const& e)
378 {
379 try
380 {
381@@ -127,6 +128,7 @@
382 catch (...)
383 {
384 }
385+ cerr << "create_query(): " << e.what() << endl;
386 // TODO: log error
387 throw;
388 }
389@@ -139,6 +141,7 @@
390 catch (...)
391 {
392 }
393+ cerr << "create_query(): unknown exception" << endl;
394 // TODO: log error
395 throw;
396 }
397
398=== modified file 'src/internal/zmq_middleware/ObjectAdapter.cpp'
399--- src/internal/zmq_middleware/ObjectAdapter.cpp 2013-11-21 21:44:00 +0000
400+++ src/internal/zmq_middleware/ObjectAdapter.cpp 2013-12-17 01:40:22 +0000
401@@ -380,12 +380,6 @@
402 }
403 }
404 }
405- catch (unity::Exception const& e)
406- {
407- // TODO: log this
408- cerr << "OA broker thread exception: " << e.to_string() << endl;
409- return;
410- }
411 catch (std::exception const& e)
412 {
413 // TODO: log this
414@@ -541,12 +535,6 @@
415 }
416 }
417 }
418- catch (unity::Exception const& e)
419- {
420- // TODO: log this
421- cerr << "OA worker thread exception: " << e.to_string() << endl;
422- return;
423- }
424 catch (std::exception const& e)
425 {
426 // TODO: log this
427
428=== modified file 'src/internal/zmq_middleware/ServantBase.cpp'
429--- src/internal/zmq_middleware/ServantBase.cpp 2013-11-21 21:44:00 +0000
430+++ src/internal/zmq_middleware/ServantBase.cpp 2013-12-17 01:40:22 +0000
431@@ -82,10 +82,6 @@
432 dispatch_(current, in_params, r);
433 return;
434 }
435- catch (unity::Exception const& e)
436- {
437- error = e.to_string();
438- }
439 catch (std::exception const& e)
440 {
441 error = e.what();
442
443=== modified file 'test/gtest/scopes/ScopeExceptions/ScopeExceptions_test.cpp'
444--- test/gtest/scopes/ScopeExceptions/ScopeExceptions_test.cpp 2013-11-01 12:44:48 +0000
445+++ test/gtest/scopes/ScopeExceptions/ScopeExceptions_test.cpp 2013-12-17 01:40:22 +0000
446@@ -27,7 +27,7 @@
447 {
448 {
449 MiddlewareException e("some error");
450- EXPECT_STREQ("unity::api::scopes::MiddlewareException", e.what());
451+ EXPECT_STREQ("unity::api::scopes::MiddlewareException: some error", e.what());
452 EXPECT_THROW(rethrow_exception(e.self()), MiddlewareException);
453 MiddlewareException e2("blah");
454 e2 = e;
455@@ -39,7 +39,7 @@
456 {
457 {
458 ConfigException e("some error");
459- EXPECT_STREQ("unity::api::scopes::ConfigException", e.what());
460+ EXPECT_STREQ("unity::api::scopes::ConfigException: some error", e.what());
461 EXPECT_THROW(rethrow_exception(e.self()), ConfigException);
462 ConfigException e2("blah");
463 e2 = e;
464@@ -51,7 +51,7 @@
465 {
466 {
467 NotFoundException e("some error", "name");
468- EXPECT_STREQ("unity::api::scopes::NotFoundException", e.what());
469+ EXPECT_STREQ("unity::api::scopes::NotFoundException: some error (name = name)", e.what());
470 EXPECT_EQ("name", e.name());
471 EXPECT_THROW(rethrow_exception(e.self()), NotFoundException);
472 NotFoundException e2("blah", "name");

Subscribers

People subscribed via source and target branches

to all changes: