defaultErrors[Error::UNKNOWN] = __('An unknown error occurred.', 'mailpoet'); if ($e instanceof Exception) { $errors = $e->getErrors() ?: $this->defaultErrors; $statusCode = $e instanceof HttpAwareException ? $e->getHttpStatusCode() : Response::STATUS_UNKNOWN; return new ErrorResponse($errors, [], $statusCode); } return new ErrorResponse($this->defaultErrors, [], Response::STATUS_UNKNOWN); } }