Migrate decaf Exceptions#54
Conversation
8c5086f to
7ca0f7f
Compare
|
@copilot can you help to review? |
Here's my review of the 19 commits migrating decaf exceptions to std C++ equivalents (590 files changed): Overall approach is sound. The migration consistently replaces decaf custom exception classes with their std equivalents:
Bug fixed (commit
Observations for awareness (not blocking):
The new |
@copilot what is the correct way to do? also removing the try/catch, is that the correct way? |
blackb1rd
left a comment
There was a problem hiding this comment.
Inconsistent FILE/LINE inclusion — Some new exceptions include source location in the message (e.g., std::invalid_argument(std::string(FILE) + ":" + std::to_string(LINE) + ": " + msg)), while others don't (e.g., std::logic_error("Connection Id must be set.")). Consistent inclusion of source location would aid debugging.
we need FILE and LINE.
What is the correct mapping? The mappings used in this PR are the right ones. The std C++ hierarchy is narrower than the original decaf hierarchy, so the closest semantic matches are:
An alternative would be to define thin custom wrappers that still derive from std types (e.g., Is removing try/catch the correct way? Yes, in the cases where it was removed it's correct. The try/catch blocks that were removed were only doing exception type translation, not adding actual handling logic. For example // BEFORE: wrapping only to convert everything to NullPointerException
try { this->checkMapIsUnmarshalled(); return *map; }
AMQ_CATCH_RETHROW(NullPointerException)
AMQ_CATCH_EXCEPTION_CONVERT(Exception, NullPointerException)
AMQ_CATCHALL_THROW(NullPointerException)Since catch (std::exception & ex) {
throw cms::CMSException(ex.what(), NULL);
}So For |
There was a problem hiding this comment.
InterruptedException → std::runtime_error is the most semantically awkward mapping. There is no std::interrupted_exception in the standard library, so std::runtime_error is the pragmatic choice. However, catch sites that previously caught only InterruptedException now catch all std::runtime_error, which is a broader type. This is an acceptable tradeoff given the constraints.
Exception hierarchy conflation — NullPointerException, IllegalStateException, UnsupportedOperationException, and IllegalMonitorStateException all map to std::logic_error. Code that previously caught one specific type now catches all of them. This is a known trade-off of migrating to a narrower std hierarchy.
The standard C++ idiom to solve this is not to replace Decaf exceptions strictly with std::logic_error or std::runtime_error, but rather to create a thin custom exception hierarchy that inherits from the <stdexcept> base classes.
1aad178 to
b2a3b47
Compare
|
@copilot please help review again. |
41b8523 to
5924d6b
Compare
| using namespace decaf; | ||
| using namespace decaf::nio; | ||
| #include <activemq/exceptions/StdExceptionTypes.h> | ||
| #include <decaf/lang/Exception.h> |
9379573 to
3913b60
Compare
334218b to
09d5272
Compare
|
@copilot please review again |
96b1a02 to
8914abc
Compare
| } \ | ||
| throw CMSException("caught unknown exception", NULL); \ | ||
| #define CMSTEMPLATE_CATCHALL(t) \ | ||
| catch (::activemq::exceptions::IllegalStateException & ex) \ |
There was a problem hiding this comment.
I though, we remove decaf but keep cms::CMSException
| { | ||
| throw CMSExceptionSupport::create(ex); | ||
| } | ||
| AMQ_CATCH_DECAF_IOSTREAM_TO_CMS_MESSAGE() |
There was a problem hiding this comment.
not quite sure why we have decaf here.
There was a problem hiding this comment.
This class extends FilterOutputStream which is under DECAF API. When we migrate this Decaf API to c++ in future iterations this will get migrated with that as well.
8914abc to
a8feebe
Compare
a8feebe to
7763f0e
Compare
https://makroo2o.atlassian.net/browse/PM-970