Invalid API endpoint exception improvement
MAILPOET-6022
This commit is contained in:
committed by
Aschepikov
parent
a7df6b496f
commit
95e595de42
@@ -269,10 +269,17 @@ class API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function createErrorResponse($errorType, $errorMessage, $responseStatus) {
|
public function createErrorResponse($errorType, $errorMessage, $responseStatus) {
|
||||||
$errorResponse = new ErrorResponse(
|
$errorMessages = [
|
||||||
[
|
|
||||||
$errorType => $errorMessage,
|
$errorType => $errorMessage,
|
||||||
],
|
];
|
||||||
|
|
||||||
|
if ($errorType === Error::BAD_REQUEST) {
|
||||||
|
$mpReinstallErrorMessage = __('The plugin has encountered an unexpected error. Please reload the page. If that does not help, re-install the MailPoet Plugin. See: https://kb.mailpoet.com/article/258-re-installing-updating-the-plugin-via-ftp', 'mailpoet');
|
||||||
|
$errorMessages[Error::REINSTALL_PLUGIN] = $mpReinstallErrorMessage; // not all places on the frontend accept html for an error message. we want this to be backwards compatible
|
||||||
|
}
|
||||||
|
|
||||||
|
$errorResponse = new ErrorResponse(
|
||||||
|
$errorMessages,
|
||||||
[],
|
[],
|
||||||
$responseStatus
|
$responseStatus
|
||||||
);
|
);
|
||||||
|
@@ -8,6 +8,7 @@ final class Error {
|
|||||||
const UNAUTHORIZED = 'unauthorized';
|
const UNAUTHORIZED = 'unauthorized';
|
||||||
const FORBIDDEN = 'forbidden';
|
const FORBIDDEN = 'forbidden';
|
||||||
const NOT_FOUND = 'not_found';
|
const NOT_FOUND = 'not_found';
|
||||||
|
const REINSTALL_PLUGIN = 'reinstall_plugin';
|
||||||
|
|
||||||
private function __construct() {
|
private function __construct() {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user