Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions modules/openapi-generator/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -482,17 +482,20 @@ use {{invokerPackage}}\ObjectSerializer;
{{/returnType}}
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
if ($exception instanceof RequestException) {
throw new ApiException(
"[{$exception->getCode()}] {$exception->getMessage()}",
(int) $exception->getCode(),
$exception->getResponse() ? $exception->getResponse()->getHeaders() : null,
$exception->getResponse() ? (string) $exception->getResponse()->getBody() : null
);
}

throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
"[{$exception->getCode()}] {$exception->getMessage()}",
(int) $exception->getCode(),
null,
null
);
}
);
Expand Down
Loading