[KIP-932] Add error translation in share consumer#2287
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
b2f55e4 to
da10f75
Compare
|
|
|
I think we can create Pure python level exception instead of C Binding level and use it in C Binding. We should check the feasibility of that. Same we should do with |
|
Thanks Pranav Rathi (@pranavrth) for reviews! Regarding
Our C module cimpl loads first and error.py already does The way around it is to not grab the Python classes at startup, but lazily at the first time C |
We are fine with the current approach. No need to complicate things. |
| "closed.\n" | ||
| "\n" | ||
| "Subclass of RuntimeError. ``exception.args[0]`` is a " | ||
| ":py:class:`KafkaError`.\n" |
There was a problem hiding this comment.
These are not subtype of KafkaException so why do we keep KafkaError in these exceptions? We can keep this if its a big change right now but we don't need to keep KafkaError in these exceptions.
| PyErr_SetObject(KafkaException, eo); | ||
| Py_DECREF(eo); | ||
| } else { | ||
| PyErr_SetString(etype, buf); |
There was a problem hiding this comment.
| PyErr_SetString(etype, buf); | |
| PyErr_SetString(etype, fmt ? buf : rd_kafka_err2str(code)); |
| va_start(ap, fmt); | ||
| vsnprintf(buf, sizeof(buf), fmt, ap); | ||
| va_end(ap); |
There was a problem hiding this comment.
| va_start(ap, fmt); | |
| vsnprintf(buf, sizeof(buf), fmt, ap); | |
| va_end(ap); | |
| if(rmt) { | |
| va_start(ap, fmt); | |
| vsnprintf(buf, sizeof(buf), fmt, ap); | |
| va_end(ap); | |
| } |
| * a plain message string — the Python type already conveys the code, and these | ||
| * local errors have no retriable/fatal/abort flags worth preserving. */ | ||
| static void | ||
| ShareConsumer_PyErr_Format(rd_kafka_resp_err_t code, const char *fmt, ...) { |
There was a problem hiding this comment.
Check KafkaError_new0
| PyObject *eo = KafkaError_new0(code, "%s", buf); | ||
| if (!eo) | ||
| return; | ||
| PyErr_SetObject(KafkaException, eo); | ||
| Py_DECREF(eo); |
There was a problem hiding this comment.
Use cfl_PyErr_Format instead.
| ShareConsumer_PyErr_Format(RD_KAFKA_RESP_ERR__STATE, "%s", | ||
| ERR_MSG_SHARE_CONSUMER_CLOSED); |
There was a problem hiding this comment.
| ShareConsumer_PyErr_Format(RD_KAFKA_RESP_ERR__STATE, "%s", | |
| ERR_MSG_SHARE_CONSUMER_CLOSED); | |
| PyErr_SetString(IllegalStateException, | |
| ERR_MSG_SHARE_CONSUMER_CLOSED); |
Same at other places
| # These subclass RuntimeError; str(exc) is the error message (not a KafkaError). | ||
| class IllegalStateException(RuntimeError): | ||
| def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
| args: Tuple[Any, ...] | ||
|
|
||
| class ConcurrentModificationException(RuntimeError): | ||
| def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
| args: Tuple[Any, ...] |
There was a problem hiding this comment.
Check if anything changed after we changed these errors to not take KafkaError
Pranav Rathi (pranavrth)
left a comment
There was a problem hiding this comment.
Build is failing. Check that.
Provided minor comment to be resolved in next PR.
Apart from that, LGTM!. Thanks Kaushik Raina (@k-raina) !.
| if (!eo) | ||
| return; |
There was a problem hiding this comment.
We should remove this as it is not setting error and returning as it is.
|
c0ef4b5
into
dev_kip-932_queues-for-kafka


Why
Notes / caveats