Skip to content

Commit 272ac86

Browse files
authored
Aligned exception handling of *AsyncWithHttpInfo with handling from *WithHttpInfo
1 parent e6ef8ee commit 272ac86

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

  • modules/openapi-generator/src/main/resources/php

modules/openapi-generator/src/main/resources/php/api.mustache

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -482,17 +482,20 @@ use {{invokerPackage}}\ObjectSerializer;
482482
{{/returnType}}
483483
},
484484
function ($exception) {
485-
$response = $exception->getResponse();
486-
$statusCode = $response->getStatusCode();
485+
if ($exception instanceof RequestException) {
486+
throw new ApiException(
487+
"[{$exception->getCode()}] {$exception->getMessage()}",
488+
(int) $exception->getCode(),
489+
$exception->getResponse() ? $exception->getResponse()->getHeaders() : null,
490+
$exception->getResponse() ? (string) $exception->getResponse()->getBody() : null
491+
);
492+
}
493+
487494
throw new ApiException(
488-
sprintf(
489-
'[%d] Error connecting to the API (%s)',
490-
$statusCode,
491-
$exception->getRequest()->getUri()
492-
),
493-
$statusCode,
494-
$response->getHeaders(),
495-
(string) $response->getBody()
495+
"[{$exception->getCode()}] {$exception->getMessage()}",
496+
(int) $exception->getCode(),
497+
null,
498+
null
496499
);
497500
}
498501
);

0 commit comments

Comments
 (0)