diff --git a/src/Api/FingerprintApi.php b/src/Api/FingerprintApi.php index 4c11953e..3cfc58ed 100644 --- a/src/Api/FingerprintApi.php +++ b/src/Api/FingerprintApi.php @@ -83,6 +83,7 @@ public function getConfig() * @throws \Fingerprint\ServerAPI\ApiException on non-2xx response * @throws \InvalidArgumentException * @throws SerializationException + * @throws GuzzleException * @return array{ \Fingerprint\ServerAPI\Model\EventResponse|null, \Psr\Http\Message\ResponseInterface } */ public function getEvent($request_id) @@ -126,7 +127,7 @@ public function getEvent($request_id) try { $serialized = ObjectSerializer::deserialize($responseBody, $returnType, []); } catch (\Exception $e) { - throw new SerializationException($response); + throw new SerializationException($response, $e); } return [$serialized, $response]; @@ -249,6 +250,7 @@ protected function getEventRequest($request_id) * @throws \Fingerprint\ServerAPI\ApiException on non-2xx response * @throws \InvalidArgumentException * @throws SerializationException + * @throws GuzzleException * @return array{ \Fingerprint\ServerAPI\Model\Response|null, \Psr\Http\Message\ResponseInterface } */ public function getVisits($visitor_id, $request_id = null, $linked_id = null, $limit = null, $pagination_key = null, $before = null) @@ -292,7 +294,7 @@ public function getVisits($visitor_id, $request_id = null, $linked_id = null, $l try { $serialized = ObjectSerializer::deserialize($responseBody, $returnType, []); } catch (\Exception $e) { - throw new SerializationException($response); + throw new SerializationException($response, $e); } return [$serialized, $response]; diff --git a/src/SerializationException.php b/src/SerializationException.php index ccbb578b..0214a464 100644 --- a/src/SerializationException.php +++ b/src/SerializationException.php @@ -9,7 +9,7 @@ final class SerializationException extends Exception { protected readonly ResponseInterface $response; -public function __construct(ResponseInterface $response, Exception $prev) + public function __construct(ResponseInterface $response, Exception $prev) { parent::__construct("Response from the server couldn't be serialized", $prev->getCode(), $prev); $this->response = $response; diff --git a/template/api.mustache b/template/api.mustache index 80456da1..da7fee4e 100644 --- a/template/api.mustache +++ b/template/api.mustache @@ -84,6 +84,7 @@ use {{invokerPackage}}\SerializationException; * @throws {{backSlash}}{{invokerPackage}}\ApiException on non-2xx response * @throws \InvalidArgumentException * @throws SerializationException + * @throws GuzzleException * @return array{ {{#returnType}}{{{returnType}}}|null{{/returnType}}{{^returnType}}null{{/returnType}}, \Psr\Http\Message\ResponseInterface } */ public function {{operationId}}({{#parameters}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/parameters}}) @@ -128,7 +129,7 @@ use {{invokerPackage}}\SerializationException; try { $serialized = ObjectSerializer::deserialize($responseBody, $returnType, []); } catch (\Exception $e) { - throw new SerializationException($response); + throw new SerializationException($response, $e); } return [$serialized, $response]; diff --git a/test/FingerprintApiTest.php b/test/FingerprintApiTest.php index 64152ec6..3ee91f78 100644 --- a/test/FingerprintApiTest.php +++ b/test/FingerprintApiTest.php @@ -90,7 +90,7 @@ public function getEventWithHttpInfoMock($request_id): array try { $serialized = ObjectSerializer::deserialize($events_mock_data, EventResponse::class); } catch (Exception $exception) { - throw new SerializationException($response); + throw new SerializationException($response, $exception); } return [$serialized, $response]; @@ -117,7 +117,7 @@ public function getVisitsWithHttpInfoMock($visitor_id, $request_id = null, $link try { $serialized = ObjectSerializer::deserialize($visits_mock_data, Response::class); } catch (Exception $exception) { - throw new SerializationException($response); + throw new SerializationException($response, $exception); } return [$serialized, $response];