1717use Jobcloud \Kafka \SchemaRegistryClient \Exception \UnauthorizedException ;
1818use Jobcloud \Kafka \SchemaRegistryClient \Exception \UnprocessableEntityException ;
1919use Jobcloud \Kafka \SchemaRegistryClient \Exception \VersionNotFoundException ;
20+ use Psr \Http \Message \RequestInterface ;
2021use Psr \Http \Message \ResponseInterface ;
2122
2223class ErrorHandler implements ErrorHandlerInterface
2324{
2425 /**
25- * @param ResponseInterface $response
26- * @param string|null $uri
26+ * @param ResponseInterface $response
27+ * @param string|null $uri
28+ * @param RequestInterface|null $request
2729 * @return void
2830 * @throws BackendDatastoreException
2931 * @throws ClientException
@@ -41,7 +43,7 @@ class ErrorHandler implements ErrorHandlerInterface
4143 * @throws VersionNotFoundException
4244 * @throws ImportException
4345 */
44- public function handleError (ResponseInterface $ response , string $ uri = null ): void
46+ public function handleError (ResponseInterface $ response , string $ uri = null , RequestInterface $ request = null ): void
4547 {
4648 $ responseContent = json_decode ($ response ->getBody (), true , 512 , JSON_THROW_ON_ERROR );
4749
@@ -56,6 +58,10 @@ public function handleError(ResponseInterface $response, string $uri = null): vo
5658 $ message .= sprintf (' (%s) ' , $ uri );
5759 }
5860
61+ if (null !== $ request ) {
62+ $ message .= sprintf (' with request body: %s ' , $ request ->getBody ()->getContents ());
63+ }
64+
5965 switch ($ code ) {
6066 case 50001 :
6167 throw new BackendDatastoreException ($ message );
0 commit comments