Move WP translation function from __construct
According to this post https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/, we are currently doing_it_wrong MAILPOET-6298
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
1f21add146
commit
6ea5074649
@ -7,15 +7,11 @@ use MailPoet\HttpAwareException;
|
||||
|
||||
class ErrorHandler {
|
||||
/** @var string[] */
|
||||
private $defaultErrors;
|
||||
|
||||
public function __construct() {
|
||||
$this->defaultErrors = [
|
||||
Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet'),
|
||||
];
|
||||
}
|
||||
private $defaultErrors = [];
|
||||
|
||||
public function convertToResponse(\Throwable $e): ErrorResponse {
|
||||
$this->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;
|
||||
|
Reference in New Issue
Block a user