Skip to content
Merged
Changes from all commits
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
15 changes: 10 additions & 5 deletions lib/Api/RaiAcceptAPIApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,20 @@ public function processRequest(Request $request, $target_structure, $error_struc
'response' => $response,
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 400:
$status = (int) $e->getCode();
$body = $e->getResponseBody();
// Refusals and client errors may use 400, 403, 422, etc. — same ErrorResponse JSON shape.
if ( $status >= 400 && $status < 500 && is_string( $body ) && $body !== '' ) {
try {
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
$body,
$error_structure,
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
$e->setResponseObject( $data );
} catch ( \Throwable $t ) {
// Body may not be ErrorResponse JSON (e.g. HTML proxy error).
}
}
throw $e;
}
Expand Down
Loading