Skip to content

Commit 27fca73

Browse files
DemetrisChravsej
andauthored
Show retry reasons even if no retries were attempted (#122)
* Show retry reasons even if no retries were attempted * fix lint warnings --------- Co-authored-by: Sergey Avseyev <[email protected]>
1 parent 15e586b commit 27fca73

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ext/couchbase.cxx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,16 +1013,14 @@ cb_map_error_code(const couchbase::key_value_error_context& ctx, const std::stri
10131013
rb_hash_aset(enhanced_error_info, rb_id2sym(rb_intern("context")), cb_str_new(ctx.extended_error_info()->context()));
10141014
rb_hash_aset(error_context, rb_id2sym(rb_intern("extended_error_info")), enhanced_error_info);
10151015
}
1016-
if (ctx.retry_attempts() > 0) {
1017-
rb_hash_aset(error_context, rb_id2sym(rb_intern("retry_attempts")), INT2FIX(ctx.retry_attempts()));
1018-
if (!ctx.retry_reasons().empty()) {
1019-
VALUE retry_reasons = rb_ary_new_capa(static_cast<long>(ctx.retry_reasons().size()));
1020-
for (const auto& reason : ctx.retry_reasons()) {
1021-
auto reason_str = fmt::format("{}", reason);
1022-
rb_ary_push(retry_reasons, rb_id2sym(rb_intern(reason_str.c_str())));
1023-
}
1024-
rb_hash_aset(error_context, rb_id2sym(rb_intern("retry_reasons")), retry_reasons);
1025-
}
1016+
rb_hash_aset(error_context, rb_id2sym(rb_intern("retry_attempts")), INT2FIX(ctx.retry_attempts()));
1017+
if (!ctx.retry_reasons().empty()) {
1018+
VALUE retry_reasons = rb_ary_new_capa(static_cast<long>(ctx.retry_reasons().size()));
1019+
for (const auto& reason : ctx.retry_reasons()) {
1020+
auto reason_str = fmt::format("{}", reason);
1021+
rb_ary_push(retry_reasons, rb_id2sym(rb_intern(reason_str.c_str())));
1022+
}
1023+
rb_hash_aset(error_context, rb_id2sym(rb_intern("retry_reasons")), retry_reasons);
10261024
}
10271025
if (ctx.last_dispatched_to()) {
10281026
rb_hash_aset(error_context, rb_id2sym(rb_intern("last_dispatched_to")), cb_str_new(ctx.last_dispatched_to().value()));

0 commit comments

Comments
 (0)