Commit 610aeca6 authored by Michael Waack's avatar Michael Waack Committed by Ralf Zimmermann
Browse files

[BUGFIX] Pass error arguments to translator

Resolves: #88022
Releases: master, 9.5
Change-Id: I7d86f8061d71357307d939d4c4359e9da1b2c68a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60549


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarDominik Merkel <merkel.dominik@googlemail.com>
Tested-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Tested-by: default avatarRalf Zimmermann <ralf.zimmermann@tritum.de>
Reviewed-by: default avatarDominik Merkel <merkel.dominik@googlemail.com>
Reviewed-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Björn Jacob's avatarBjörn Jacob <bjoern.jacob@tritum.de>
Reviewed-by: default avatarRalf Zimmermann <ralf.zimmermann@tritum.de>
parent 5ecb5034
......@@ -15,9 +15,9 @@ ignoreFiles=()
# auto generated file, shouldn't be checked
ignoreFiles+="sysext/core/Tests/Acceptance/Support/_generated/BackendTesterActions.php"
ignoreFiles+="sysext/core/Tests/Acceptance/Support/_generated/InstallTesterActions.php"
# a exception in here throws up an code from a previous exception
# an exception in here throws a code from a previous exception/error
ignoreFiles+="sysext/extbase/Classes/Core/Bootstrap.php"
ignoreFiles+="sysext/form/Classes/Mvc/Property/TypeConverter/UploadedFileReferenceConverter.php"
ignoreFiles+="sysext/form/Classes/Mvc/Property/Exception/TypeConverterException.php"
foundNewFile=0
oldFilename=""
......
<?php
namespace TYPO3\CMS\Form\Mvc\Property\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Extbase\Error\Error;
/**
* A "Type Converter" Exception
*/
class TypeConverterException extends \TYPO3\CMS\Extbase\Property\Exception\TypeConverterException
{
/**
* @var Error
*/
protected $error;
public static function fromError(Error $error): TypeConverterException
{
$exception = new static($error->getMessage(), $error->getCode());
$exception->error = $error;
return $exception;
}
public function getError(): Error
{
if (empty($this->error)) {
return new Error($this->getMessage(), $this->getCode(), [$this->getPrevious()]);
}
return $this->error;
}
}
......@@ -22,10 +22,10 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\AbstractFileFolder;
use TYPO3\CMS\Extbase\Domain\Model\FileReference as ExtbaseFileReference;
use TYPO3\CMS\Extbase\Error\Error;
use TYPO3\CMS\Extbase\Property\Exception\TypeConverterException;
use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface;
use TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter;
use TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator;
use TYPO3\CMS\Form\Mvc\Property\Exception\TypeConverterException;
use TYPO3\CMS\Form\Service\TranslationService;
/**
......@@ -172,6 +172,8 @@ class UploadedFileReferenceConverter extends AbstractTypeConverter
try {
$resource = $this->importUploadedResource($source, $configuration);
} catch (TypeConverterException $e) {
return $e->getError();
} catch (\Exception $e) {
return $this->objectManager->get(Error::class, $e->getMessage(), $e->getCode());
}
......@@ -186,7 +188,6 @@ class UploadedFileReferenceConverter extends AbstractTypeConverter
* @param array $uploadInfo
* @param PropertyMappingConfigurationInterface $configuration
* @return ExtbaseFileReference
* @throws TypeConverterException
*/
protected function importUploadedResource(
array $uploadInfo,
......@@ -209,7 +210,7 @@ class UploadedFileReferenceConverter extends AbstractTypeConverter
$validationResult = $validator->validate($uploadedFile);
if ($validationResult->hasErrors()) {
$uploadedFile->getStorage()->deleteFile($uploadedFile);
throw new TypeConverterException($validationResult->getErrors()[0]->getMessage(), $validationResult->getErrors()[0]->getCode());
throw TypeConverterException::fromError($validationResult->getErrors()[0]);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment