You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by nk...@apache.org on 2019/06/13 06:29:03 UTC
[pulsar-client-node] 26/36: fix error handling about hasNext
This is an automated email from the ASF dual-hosted git repository.
nkurihar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit be89b1682e2729a73d9c15f0869d1b756f49a5f5
Author: yfuruta <yf...@yahoo-corp.jp>
AuthorDate: Tue Jun 11 19:03:09 2019 +0900
fix error handling about hasNext
---
src/Reader.cc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/Reader.cc b/src/Reader.cc
index 8c2b859..cfca247 100644
--- a/src/Reader.cc
+++ b/src/Reader.cc
@@ -146,7 +146,10 @@ Napi::Value Reader::ReadNext(const Napi::CallbackInfo &info) {
Napi::Value Reader::HasNext(const Napi::CallbackInfo &info) {
int value = 0;
pulsar_result result = pulsar_reader_has_message_available(this->cReader, &value);
- if (result != pulsar_result_Ok || value != 1) {
+ if (result != pulsar_result_Ok) {
+ Napi::Error::New(info.Env(), "Failed to check if next message is available").ThrowAsJavaScriptException();
+ return Napi::Boolean::New(info.Env(), false);
+ } else if (value != 1) {
return Napi::Boolean::New(info.Env(), false);
} else {
return Napi::Boolean::New(info.Env(), true);