|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
| 17 | +#include "core_error_info.hxx" |
17 | 18 | #include "wrapper.hxx"
|
18 | 19 |
|
19 | 20 | #include "common.hxx"
|
@@ -702,6 +703,34 @@ error_context_to_zval(const empty_error_context& /* ctx */,
|
702 | 703 | /* nothing to do */
|
703 | 704 | }
|
704 | 705 |
|
| 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 | + |
705 | 734 | COUCHBASE_API
|
706 | 735 | void
|
707 | 736 | error_context_to_zval(const core_error_info& info,
|
|
0 commit comments