File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -137,11 +137,7 @@ public function assert(?Throwable $e = null): void
137
137
assertNotNull ($ e );
138
138
139
139
if (isset ($ this ->isClientError )) {
140
- if ($ this ->isClientError ) {
141
- assertNotInstanceOf (ServerException::class, $ e );
142
- } else {
143
- assertInstanceOf (ServerException::class, $ e );
144
- }
140
+ $ this ->assertIsClientError ($ e );
145
141
}
146
142
147
143
if (isset ($ this ->messageContains )) {
@@ -176,6 +172,21 @@ public function assert(?Throwable $e = null): void
176
172
}
177
173
}
178
174
175
+ private function assertIsClientError (Throwable $ e ): void
176
+ {
177
+ /* Note: BulkWriteException may proxy a previous exception. Unwrap it
178
+ * to check the original error. */
179
+ if ($ e instanceof BulkWriteException && $ e ->getPrevious () !== null ) {
180
+ $ e = $ e ->getPrevious ();
181
+ }
182
+
183
+ if ($ this ->isClientError ) {
184
+ assertNotInstanceOf (ServerException::class, $ e );
185
+ } else {
186
+ assertInstanceOf (ServerException::class, $ e );
187
+ }
188
+ }
189
+
179
190
private function assertCodeName (ServerException $ e ): void
180
191
{
181
192
/* BulkWriteException and ExecutionTimeoutException do not expose
You can’t perform that action at this time.
0 commit comments