withErrorCode(self::MIGRATION_FAILED) ->withMessage(__(sprintf('Migration failed: %s', $error), 'mailpoet')); } public static function databaseError(string $error): InvalidStateException { return InvalidStateException::create() ->withErrorCode(self::DATABASE_ERROR) ->withMessage(__(sprintf('Database error: %s', $error), 'mailpoet')); } public static function apiMethodNotAllowed(): UnexpectedValueException { return UnexpectedValueException::create() ->withStatusCode(405) ->withErrorCode(self::API_METHOD_NOT_ALLOWED) ->withMessage(__('Method not allowed.', 'mailpoet')); } public static function apiNoJsonBody(): UnexpectedValueException { return UnexpectedValueException::create() ->withErrorCode(self::API_NO_JSON_BODY) ->withMessage(__('No JSON body passed.', 'mailpoet')); } }