You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/07/01 08:04:19 UTC
[rocketmq-clients] 06/18: Add error handling for ReceiveMessage
This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch cpp
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
commit b4a2e50fa67be0eb9777232d4b668f507608de99
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Thu Jun 30 17:21:02 2022 +0800
Add error handling for ReceiveMessage
---
.../main/cpp/client/ReceiveMessageStreamReader.cpp | 50 +++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/cpp/src/main/cpp/client/ReceiveMessageStreamReader.cpp b/cpp/src/main/cpp/client/ReceiveMessageStreamReader.cpp
index 3ee8f68..0684f51 100644
--- a/cpp/src/main/cpp/client/ReceiveMessageStreamReader.cpp
+++ b/cpp/src/main/cpp/client/ReceiveMessageStreamReader.cpp
@@ -17,7 +17,10 @@
#include "ReceiveMessageStreamReader.h"
+#include <apache/rocketmq/v2/definition.pb.h>
+
#include "LoggerImpl.h"
+#include "rocketmq/ErrorCode.h"
ROCKETMQ_NAMESPACE_BEGIN
@@ -63,6 +66,26 @@ void ReceiveMessageStreamReader::OnReadDone(bool ok) {
case rmq::Code::OK: {
break;
}
+ case rmq::Code::ILLEGAL_TOPIC: {
+ ec_ = ErrorCode::IllegalTopic;
+ break;
+ }
+
+ case rmq::Code::ILLEGAL_CONSUMER_GROUP: {
+ ec_ = ErrorCode::IllegalConsumerGroup;
+ break;
+ }
+
+ case rmq::Code::ILLEGAL_FILTER_EXPRESSION: {
+ ec_ = ErrorCode::IllegalFilterExpression;
+ break;
+ }
+
+ case rmq::Code::CLIENT_ID_REQUIRED: {
+ ec_ = ErrorCode::ClientIdRequired;
+ break;
+ }
+
case rmq::Code::TOPIC_NOT_FOUND: {
ec_ = ErrorCode::TopicNotFound;
break;
@@ -72,17 +95,42 @@ void ReceiveMessageStreamReader::OnReadDone(bool ok) {
ec_ = ErrorCode::ConsumerGroupNotFound;
break;
}
+
case rmq::Code::TOO_MANY_REQUESTS: {
ec_ = ErrorCode::TooManyRequests;
break;
}
+
case rmq::Code::MESSAGE_NOT_FOUND: {
ec_ = ErrorCode::NoContent;
break;
}
- default:
+
+ case rmq::Code::UNAUTHORIZED: {
+ ec_ = ErrorCode::Unauthorized;
+ break;
+ }
+
+ case rmq::Code::FORBIDDEN: {
+ ec_ = ErrorCode::Forbidden;
+ break;
+ }
+
+ case rmq::Code::INTERNAL_SERVER_ERROR: {
+ ec_ = ErrorCode::InternalServerError;
+ break;
+ }
+
+ case rmq::Code::PROXY_TIMEOUT: {
+ ec_ = ErrorCode::GatewayTimeout;
+ break;
+ }
+
+ default: {
+ ec_ = ErrorCode::NotSupported;
SPDLOG_WARN("Unsupported code={}", response_.status().code());
break;
+ }
}
break;
}