Skip to content

Commit 12caef7

Browse files
committed
1 parent ea4baa4 commit 12caef7

9 files changed

+624
-475
lines changed

src/wrapper/common.cxx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include "core_error_info.hxx"
1718
#include "wrapper.hxx"
1819

1920
#include "common.hxx"
@@ -702,6 +703,34 @@ error_context_to_zval(const empty_error_context& /* ctx */,
702703
/* nothing to do */
703704
}
704705

706+
COUCHBASE_API
707+
void
708+
error_context_to_zval(const generic_error_context& ctx,
709+
zval* return_value,
710+
std::string& enhanced_error_message)
711+
{
712+
if (!ctx.message.empty()) {
713+
if (!enhanced_error_message.empty()) {
714+
enhanced_error_message.append(", ");
715+
}
716+
enhanced_error_message.append(ctx.message);
717+
add_assoc_stringl(return_value, "message", ctx.message.data(), ctx.message.size());
718+
}
719+
if (!ctx.json_data.empty()) {
720+
if (!enhanced_error_message.empty()) {
721+
enhanced_error_message.append(", ");
722+
}
723+
enhanced_error_message.append(ctx.json_data);
724+
add_assoc_stringl(return_value, "json", ctx.json_data.data(), ctx.json_data.size());
725+
}
726+
if (ctx.cause != nullptr) {
727+
zval cause;
728+
array_init(&cause);
729+
error_context_to_zval(*ctx.cause, &cause, enhanced_error_message);
730+
add_assoc_zval(return_value, "cause", &cause);
731+
}
732+
}
733+
705734
COUCHBASE_API
706735
void
707736
error_context_to_zval(const core_error_info& info,

0 commit comments

Comments
 (0)