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


The following commit(s) were added to refs/heads/cpp by this push:
     new 256f659  Add error handling for ReceiveMessage
256f659 is described below

commit 256f6593def309c41012a131069537e135bac4be
Author: Li Zhanhui <[email protected]>
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;
     }

Reply via email to