Conditions | 5 |
Paths | 5 |
Total Lines | 29 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | public function inspect(ResponseInterface $response) |
||
16 | { |
||
17 | $this->filterCommonErrors($response); |
||
18 | switch ($response->getStatusCode()) { |
||
19 | |||
20 | /* OK */ |
||
21 | case 201: |
||
22 | break; |
||
23 | |||
24 | /* |
||
25 | * The ES Api will try to redirect us if we do not provide an eventId. |
||
26 | * Actually this client is designed to avoid that scenario. |
||
27 | * The httpClient does not allow redirects anyway. |
||
28 | * See: http://docs.geteventstore.com/http-api/3.4.0/writing-to-a-stream/#expected-version |
||
29 | */ |
||
30 | case 301: |
||
31 | throw new \LogicException('Please help us understand how you got here!!!'); |
||
32 | |||
33 | /* Catch known error, otherwise fall-through to a more generic exception. */ |
||
34 | case 400: |
||
35 | if ($response->getReasonPhrase() == 'Wrong expected EventNumber') { |
||
36 | throw new WrongExpectedVersionException(); |
||
37 | } |
||
38 | |||
39 | /* KO. */ |
||
40 | default: |
||
41 | throw $this->newBadRequestException($response); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 |