Propagate error details to REST API responses

[MAILPOET-4659]
This commit is contained in:
Jan Jakes
2022-10-03 15:55:02 +02:00
committed by Jan Jakeš
parent 6638707282
commit 14eb8db540
2 changed files with 7 additions and 3 deletions

View File

@@ -80,7 +80,7 @@ class API {
private function convertToErrorResponse(Throwable $e): ErrorResponse {
$response = $e instanceof Exception
? new ErrorResponse($e->getStatusCode(), $e->getMessage(), $e->getErrorCode())
? new ErrorResponse($e->getStatusCode(), $e->getMessage(), $e->getErrorCode(), $e->getErrors())
: new ErrorResponse(500, __('An unknown error occurred.', 'mailpoet'), 'mailpoet_automation_unknown_error');
if ($response->get_status() >= 500) {