getRequest()->getParam('rate')) { /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); try { $this->_taxRateRepository->deleteById($rateId); $this->messageManager->addSuccess(__('You deleted the tax rate.')); return $resultRedirect->setPath("*/*/"); } catch (NoSuchEntityException $e) { $this->messageManager->addError( __('We can\'t delete this rate because of an incorrect rate ID.') ); return $resultRedirect->setPath("tax/*/"); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong deleting this rate.')); } if ($this->getRequest()->getServer('HTTP_REFERER')) { $resultRedirect->setRefererUrl(); } else { $resultRedirect->setPath("*/*/"); } return $resultRedirect; } } }