17
17
use Jobcloud \Kafka \SchemaRegistryClient \Exception \UnauthorizedException ;
18
18
use Jobcloud \Kafka \SchemaRegistryClient \Exception \UnprocessableEntityException ;
19
19
use Jobcloud \Kafka \SchemaRegistryClient \Exception \VersionNotFoundException ;
20
+ use Psr \Http \Message \RequestInterface ;
20
21
use Psr \Http \Message \ResponseInterface ;
21
22
22
23
class ErrorHandler implements ErrorHandlerInterface
23
24
{
24
25
/**
25
- * @param ResponseInterface $response
26
- * @param string|null $uri
26
+ * @param ResponseInterface $response
27
+ * @param string|null $uri
28
+ * @param RequestInterface|null $request
27
29
* @return void
28
30
* @throws BackendDatastoreException
29
31
* @throws ClientException
@@ -41,7 +43,7 @@ class ErrorHandler implements ErrorHandlerInterface
41
43
* @throws VersionNotFoundException
42
44
* @throws ImportException
43
45
*/
44
- public function handleError (ResponseInterface $ response , string $ uri = null ): void
46
+ public function handleError (ResponseInterface $ response , string $ uri = null , RequestInterface $ request = null ): void
45
47
{
46
48
$ responseContent = json_decode ($ response ->getBody (), true , 512 , JSON_THROW_ON_ERROR );
47
49
@@ -56,6 +58,10 @@ public function handleError(ResponseInterface $response, string $uri = null): vo
56
58
$ message .= sprintf (' (%s) ' , $ uri );
57
59
}
58
60
61
+ if (null !== $ request ) {
62
+ $ message .= sprintf (' with request body: %s ' , $ request ->getBody ()->getContents ());
63
+ }
64
+
59
65
switch ($ code ) {
60
66
case 50001 :
61
67
throw new BackendDatastoreException ($ message );
0 commit comments