applicationFactory->create()->load((int)$this->getRequest()->getParam('entity_id')); if (!$application->getId()) { throw new \RuntimeException('Application not found.'); } $application->delete(); $this->messageManager->addSuccessMessage(__('The application has been deleted.')); } catch (\Throwable $exception) { $this->messageManager->addErrorMessage(__('The application could not be deleted.')); } return $this->resultRedirectFactory->create()->setPath('*/*/'); } }