This is an automated email from the ASF dual-hosted git repository.
baodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
The following commit(s) were added to refs/heads/master by this push:
new dd851d2 [Improve] Improve log message for Reader.HasNext (#327)
dd851d2 is described below
commit dd851d21ddaa708b0903ad639060f9dc99428146
Author: Zike Yang <[email protected]>
AuthorDate: Thu May 18 22:58:05 2023 +0800
[Improve] Improve log message for Reader.HasNext (#327)
## Motivation
Currently if there is something wrong with
`pulsar_reader_has_message_available`, the log will not print the actual error
message. It's hard to debug without that message.
## Modification
* Add failed result message to the log in Reader::HasNext.
---
src/Reader.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/Reader.cc b/src/Reader.cc
index 5b9d8a7..bd6c7f0 100644
--- a/src/Reader.cc
+++ b/src/Reader.cc
@@ -222,7 +222,9 @@ Napi::Value Reader::HasNext(const Napi::CallbackInfo &info)
{
int value = 0;
pulsar_result result =
pulsar_reader_has_message_available(this->cReader.get(), &value);
if (result != pulsar_result_Ok) {
- Napi::Error::New(info.Env(), "Failed to check if next message is
available").ThrowAsJavaScriptException();
+ Napi::Error::New(
+ info.Env(), "Failed to check if next message is available: " +
std::string(pulsar_result_str(result)))
+ .ThrowAsJavaScriptException();
return Napi::Boolean::New(info.Env(), false);
} else if (value == 1) {
return Napi::Boolean::New(info.Env(), true);