Created
July 22, 2014 20:33
-
-
Save oliverthiele/f1550a246dd8726ef136 to your computer and use it in GitHub Desktop.
Debugging errors like "An error occurred while trying to call Vendor\ExtKey\Controller\ModelController->showAction() " in extbase extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A special action which is called if the originally intended action could | |
* not be called, for example if the arguments were not valid. | |
* | |
* The default implementation sets a flash message, request errors and forwards back | |
* to the originating action. This is suitable for most actions dealing with form input. | |
* | |
* We clear the page cache by default on an error as well, as we need to make sure the | |
* data is re-evaluated when the user changes something. | |
* | |
* @return string | |
*/ | |
protected function errorAction() { | |
echo 'ErrorAction'; | |
$this->clearCacheOnError(); | |
if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { | |
echo 'Rewritten Property Mapper'; | |
echo '<pre>'; | |
foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $propertyPath => $errors) { | |
foreach ($errors as $error) { | |
$message .= 'Error for ' . $propertyPath . ': ' . $error->render() . | |
PHP_EOL; | |
} | |
echo 'Error: ' . $message; | |
} | |
echo '</pre>'; | |
$errorFlashMessage = $this->getErrorFlashMessage(); | |
if ($errorFlashMessage !== FALSE) { | |
$errorFlashMessageObject = new \TYPO3\CMS\Core\Messaging\FlashMessage( | |
$errorFlashMessage, | |
'', | |
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR | |
); | |
$this->controllerContext->getFlashMessageQueue()->enqueue($errorFlashMessageObject); | |
} | |
$referringRequest = $this->request->getReferringRequest(); | |
if ($referringRequest !== NULL) { | |
$originalRequest = clone $this->request; | |
$this->request->setOriginalRequest($originalRequest); | |
$this->request->setOriginalRequestMappingResults($this->arguments->getValidationResults()); | |
$this->forward($referringRequest->getControllerActionName(), $referringRequest->getControllerName(), $referringRequest->getControllerExtensionName(), $referringRequest->getArguments()); | |
} | |
$message = 'An error occurred while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '().' . PHP_EOL; | |
return $message; | |
} else { | |
// @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1 | |
$this->request->setErrors($this->argumentsMappingResults->getErrors()); | |
$errorFlashMessage = $this->getErrorFlashMessage(); | |
if ($errorFlashMessage !== FALSE) { | |
$errorFlashMessageObject = new \TYPO3\CMS\Core\Messaging\FlashMessage( | |
$errorFlashMessage, | |
'', | |
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR | |
); | |
$this->controllerContext->getFlashMessageQueue()->enqueue($errorFlashMessageObject); | |
} | |
$referrer = $this->request->getInternalArgument('__referrer'); | |
if ($referrer !== NULL) { | |
$this->forward($referrer['actionName'], $referrer['controllerName'], $referrer['extensionName'], $this->request->getArguments()); | |
} | |
$message = 'An error occurred while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '().' . PHP_EOL; | |
return $message; | |
} | |
} |
Thank you so much! Saved my day!
Very helpful. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got the error now... BUT! If I clean my cache from Backend (the 3) then everything works as expected... how can this be a validation problem? ANy Idea?