@@ -77,6 +77,7 @@ const StaticString
77
77
Object hippo_write_result_init (mongoc_write_result_t *write_result, bson_error_t *error, mongoc_client_t *client, int server_id, int success, const mongoc_write_concern_t *write_concern)
78
78
{
79
79
static Class* c_writeResult;
80
+ std::string message;
80
81
81
82
c_writeResult = Unit::lookupClass (s_MongoDriverWriteResult_className.get ());
82
83
assert (c_writeResult);
@@ -94,6 +95,10 @@ Object hippo_write_result_init(mongoc_write_result_t *write_result, bson_error_t
94
95
obj->o_set (s_nModified, Variant ((int64_t ) write_result->nModified ), s_MongoDriverWriteResult_className);
95
96
obj->o_set (s_omit_nModified, Variant ((int64_t ) write_result->omit_nModified ), s_MongoDriverWriteResult_className);
96
97
98
+ if (!success) {
99
+ message = " BulkWrite error" ;
100
+ }
101
+
97
102
if (write_concern) {
98
103
Array debugInfoResult = Array::Create ();
99
104
mongodb_driver_add_write_concern_debug ((mongoc_write_concern_t *) write_concern, &debugInfoResult);
@@ -135,6 +140,8 @@ Object hippo_write_result_init(mongoc_write_result_t *write_result, bson_error_t
135
140
136
141
if (a_we.exists (s_errmsg)) {
137
142
we_obj->o_set (s_message, a_we[s_errmsg], s_MongoDriverWriteError_className);
143
+ message += " :: " ;
144
+ message.append (a_we[s_errmsg].toString ().c_str ());
138
145
}
139
146
if (a_we.exists (s_code)) {
140
147
we_obj->o_set (s_code, a_we[s_code], s_MongoDriverWriteError_className);
@@ -173,6 +180,8 @@ Object hippo_write_result_init(mongoc_write_result_t *write_result, bson_error_t
173
180
174
181
if (first_item.exists (s_errmsg)) {
175
182
wce_obj->o_set (s_message, first_item[s_errmsg], s_MongoDriverWriteConcernError_className);
183
+ message += " :: " ;
184
+ message.append (first_item[s_errmsg].toString ().c_str ());
176
185
}
177
186
if (first_item.exists (s_code)) {
178
187
wce_obj->o_set (s_code, first_item[s_code], s_MongoDriverWriteConcernError_className);
@@ -194,7 +203,7 @@ Object hippo_write_result_init(mongoc_write_result_t *write_result, bson_error_t
194
203
) {
195
204
throw MongoDriver::Utils::throwExceptionFromBsonError (error);
196
205
} else {
197
- auto bw_exception = MongoDriver::Utils::throwBulkWriteException (" BulkWrite error " );
206
+ auto bw_exception = MongoDriver::Utils::throwBulkWriteException (message );
198
207
bw_exception->o_set (s_MongoDriverExceptionBulkWriteException_writeResult, obj, MongoDriver::s_MongoDriverExceptionBulkWriteException_className);
199
208
200
209
throw bw_exception;
0 commit comments