@@ -144,57 +144,16 @@ zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_d
144
144
return php_phongo_connectiontimeoutexception_ce ;
145
145
case MONGOC_ERROR_CLIENT_AUTHENTICATE :
146
146
return php_phongo_authenticationexception_ce ;
147
-
148
147
case MONGOC_ERROR_COMMAND_INVALID_ARG :
149
148
return php_phongo_invalidargumentexception_ce ;
150
-
151
- case MONGOC_ERROR_STREAM_INVALID_TYPE :
152
- case MONGOC_ERROR_STREAM_INVALID_STATE :
153
- case MONGOC_ERROR_STREAM_NAME_RESOLUTION :
154
- case MONGOC_ERROR_STREAM_CONNECT :
155
- case MONGOC_ERROR_STREAM_NOT_ESTABLISHED :
156
- return php_phongo_connectionexception_ce ;
157
- case MONGOC_ERROR_CLIENT_NOT_READY :
158
- case MONGOC_ERROR_CLIENT_TOO_BIG :
159
- case MONGOC_ERROR_CLIENT_TOO_SMALL :
160
- case MONGOC_ERROR_CLIENT_GETNONCE :
161
- case MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER :
162
- case MONGOC_ERROR_CLIENT_IN_EXHAUST :
163
- case MONGOC_ERROR_PROTOCOL_INVALID_REPLY :
164
- case MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION :
165
- case MONGOC_ERROR_CURSOR_INVALID_CURSOR :
166
- /*case MONGOC_ERROR_PROTOCOL_ERROR:*/
167
- case MONGOC_ERROR_BSON_INVALID :
168
- case MONGOC_ERROR_MATCHER_INVALID :
169
- case MONGOC_ERROR_NAMESPACE_INVALID :
170
- case MONGOC_ERROR_GRIDFS_INVALID_FILENAME :
171
- return php_phongo_runtimeexception_ce ;
172
- case MONGOC_ERROR_QUERY_FAILURE :
173
- case MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND :
174
- case MONGOC_ERROR_QUERY_NOT_TAILABLE :
175
- case MONGOC_ERROR_COLLECTION_INSERT_FAILED :
176
- return php_phongo_serverexception_ce ;
177
149
}
178
150
switch (domain ) {
151
+ case MONGOC_ERROR_COMMAND :
152
+ // TODO: return php_phongo_commandexception_ce after PHPC-1089 is merged
179
153
case MONGOC_ERROR_SERVER :
180
154
return php_phongo_serverexception_ce ;
181
- case MONGOC_ERROR_CLIENT :
182
155
case MONGOC_ERROR_STREAM :
183
- case MONGOC_ERROR_PROTOCOL :
184
- case MONGOC_ERROR_CURSOR :
185
- case MONGOC_ERROR_QUERY :
186
- case MONGOC_ERROR_INSERT :
187
- case MONGOC_ERROR_SASL :
188
- case MONGOC_ERROR_BSON :
189
- case MONGOC_ERROR_MATCHER :
190
- case MONGOC_ERROR_NAMESPACE :
191
- case MONGOC_ERROR_COMMAND :
192
- case MONGOC_ERROR_COLLECTION :
193
- case MONGOC_ERROR_GRIDFS :
194
- /* FIXME: We don't have the Exceptions mocked yet.. */
195
- #if 0
196
- return phongo_ce_mongo_connection_exception ;
197
- #endif
156
+ return php_phongo_connectionexception_ce ;
198
157
default :
199
158
return php_phongo_runtimeexception_ce ;
200
159
}
@@ -703,7 +662,7 @@ bool phongo_execute_bulk_write(mongoc_client_t* client, const char* namespace, p
703
662
/* The Write failed */
704
663
if (!success ) {
705
664
if ((error .domain == MONGOC_ERROR_COMMAND && error .code != MONGOC_ERROR_COMMAND_INVALID_ARG ) ||
706
- error .domain == MONGOC_ERROR_WRITE_CONCERN ) {
665
+ error .domain == MONGOC_ERROR_SERVER || error . domain == MONGOC_ERROR_WRITE_CONCERN ) {
707
666
phongo_throw_exception (PHONGO_ERROR_WRITE_FAILED TSRMLS_CC , "%s" , error .message );
708
667
phongo_add_exception_prop (ZEND_STRL ("writeResult" ), return_value TSRMLS_CC );
709
668
} else {
@@ -2372,6 +2331,7 @@ void phongo_manager_init(php_phongo_manager_t* manager, const char* uri_string,
2372
2331
#endif
2373
2332
2374
2333
manager -> client = php_phongo_make_mongo_client (uri TSRMLS_CC );
2334
+ mongoc_client_set_error_api (manager -> client , MONGOC_ERROR_API_VERSION_2 );
2375
2335
2376
2336
if (!manager -> client ) {
2377
2337
phongo_throw_exception (PHONGO_ERROR_RUNTIME TSRMLS_CC , "Failed to create Manager from URI: '%s'" , uri_string );
0 commit comments