Skip to content

Commit

Permalink
EZP-31021: Revised exception and command messages (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikaK authored and adamwojs committed Dec 3, 2019
1 parent 667618a commit 59f1efa
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function process(ContainerBuilder $container)
foreach ($tags as $tag) {
if (!isset($tag['fieldType'])) {
throw new LogicException(
'`ezplatform.field_type.form_mapper` or deprecated `ez.fieldFormMapper` service tags need a "fieldType" attribute to identify which field type the mapper is for. None given.'
'`ezplatform.field_type.form_mapper` or deprecated `ez.fieldFormMapper` service tags need a "fieldType" attribute to identify which Field Type the mapper is for.'
);
}

Expand Down Expand Up @@ -66,7 +66,7 @@ private function findTaggedFormMapperServices(ContainerBuilder $container): arra
foreach ($deprecatedFieldFormMapperValueTags as $ezFieldFormMapperValueTag) {
@trigger_error(
sprintf(
'`%s` service tag is deprecated and will be removed in eZ Platform 4.0. Please use `%s` instead.',
'The `%s` service tag is deprecated and will be removed in eZ Platform 4.0. Use `%s` instead.',
self::DEPRECATED_FIELD_TYPE_FORM_MAPPER_VALUE_SERVICE_TAG,
self::FIELD_TYPE_FORM_MAPPER_VALUE_SERVICE_TAG
),
Expand All @@ -77,7 +77,7 @@ private function findTaggedFormMapperServices(ContainerBuilder $container): arra
foreach ($deprecatedFieldFormMapperDefinitionTags as $ezFieldFormMapperValueTag) {
@trigger_error(
sprintf(
'`%s` service tag is deprecated and will be removed in eZ Platform 4.0. Please use `%s` instead.',
'The `%s` service tag is deprecated and will be removed in eZ Platform 4.0. Use `%s` instead.',
self::DEPRECATED_FIELD_TYPE_FORM_MAPPER_DEFINITION_SERVICE_TAG,
self::FIELD_TYPE_FORM_MAPPER_DEFINITION_SERVICE_TAG
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container)
foreach ($attributes as $attribute) {
if (!isset($attribute['limitationType'])) {
throw new LogicException(
'ez.limitation.formMapper service tag needs a "limitationType" attribute to identify which LimitationType the mapper is for. None given.'
'ez.limitation.formMapper service tag needs a "limitationType" attribute to identify which LimitationType the mapper is for.'
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function process(ContainerBuilder $container)
foreach ($attributes as $attribute) {
if (!isset($attribute['limitationType'])) {
throw new LogicException(sprintf(
'%s service tag needs a "limitationType" attribute to identify which LimitationType the mapper is for. None given.',
'The %s service tag needs a "limitationType" attribute to identify which LimitationType the mapper is for.',
self::LIMITATION_VALUE_MAPPER_TAG
));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Behat/Context/ContentTypeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function addFieldsTo($contentTypeIdentifier, array $fieldDefinitions)
public function getCurrentContentType()
{
if ($this->currentContentType === null) {
throw new Exception('No current content type has been defined in the context');
throw new Exception('No current Content Type has been defined in the context');
}

return $this->currentContentType;
Expand Down
2 changes: 1 addition & 1 deletion lib/Behat/Context/PagelayoutContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getPageLayout(): string
? str_replace('@ezdesign', 'templates/themes/tastefulplanet', $this->configResolver->getParameter('page_layout', null, 'site'))
: str_replace('@ezdesign', 'templates/themes/tastefulplanet', $this->configResolver->getParameter('pagelayout', null, 'site'));
default:
throw new \Exception('Unrecognised install type');
throw new \Exception('Unrecognised installation type');
}
}
}
2 changes: 1 addition & 1 deletion lib/Behat/Context/SelectionFieldTypeFormContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function theSelectFieldShouldBeFlaggedAsRequired()
'required',
$nodeElement->getAttribute('required'),
sprintf(
'select with id %s is not flagged as required',
'The select with ID %s is not flagged as required',
$nodeElement->getAttribute('id')
)
);
Expand Down
2 changes: 1 addition & 1 deletion lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function setParam($name, $value)
protected function getParam($name)
{
if (!isset($this->params[$name])) {
throw new OutOfBoundsException("No such param '$name'");
throw new OutOfBoundsException("There is no param '$name'");
}

return $this->params[$name];
Expand Down
6 changes: 3 additions & 3 deletions lib/Content/View/Builder/ContentCreateViewBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function resolveLanguage(array $parameters): Language
}

throw new InvalidArgumentException('Language',
'No language information provided. Are you missing language or languageCode parameters');
'No language information provided. Are you missing language or languageCode parameters?');
}

/**
Expand All @@ -223,7 +223,7 @@ private function resolveContentType(array $parameters, array $languageCodes): Co

throw new InvalidArgumentException(
'ContentType',
'No content type could be loaded from parameters'
'No Content Type could be loaded from the parameters'
);
}

Expand All @@ -248,7 +248,7 @@ private function resolveLocation(array $parameters): Location

throw new InvalidArgumentException(
'ParentLocation',
'Unable to load parent location from parameters'
'Unable to load parent Location from the parameters'
);
}
}
8 changes: 4 additions & 4 deletions lib/Content/View/Builder/ContentEditViewBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function buildView(array $parameters)
$isPublished = null !== $contentInfo->mainLocationId && $contentInfo->published;

if (!$content->getVersionInfo()->isDraft()) {
throw new InvalidArgumentException('Version', 'status is not draft');
throw new InvalidArgumentException('Version', 'The status is not draft');
}

if (null === $location && $isPublished) {
Expand All @@ -110,7 +110,7 @@ public function buildView(array $parameters)
}

if (null !== $location && $location->contentId !== $content->id) {
throw new InvalidArgumentException('Location', 'Provided location does not belong to selected content');
throw new InvalidArgumentException('Location', 'The provided Location does not belong to the selected content');
}

if ($form->isSubmitted() && $form->isValid() && null !== $form->getClickedButton()) {
Expand Down Expand Up @@ -229,7 +229,7 @@ private function resolveLanguage(array $parameters): Language
}

throw new InvalidArgumentException('Language',
'No language information provided. Are you missing language or languageCode parameters');
'No language information provided. Are you missing language or languageCode parameters?');
}

/**
Expand All @@ -254,7 +254,7 @@ private function resolveContent(array $parameters, ?Location $location, Language
} else {
throw new InvalidArgumentException(
'Content',
'No content could be loaded from parameters'
'No content could be loaded from the parameters'
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getDefaultProperties()
public function getReverseTransformedValue($value)
{
if (!is_array($value)) {
throw new TransformationFailedException(sprintf('Expected a array got %s', gettype($value)));
throw new TransformationFailedException(sprintf('Received %s instead of an array', gettype($value)));
}

if ($value['remove']) {
Expand Down
4 changes: 2 additions & 2 deletions lib/FieldType/DataTransformer/DateTimeValueTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function transform($value)

if (!$value instanceof Value) {
throw new TransformationFailedException(
sprintf('Expected a %s, got %s instead', Value::class, gettype($value))
sprintf('Received %s instead of %s', gettype($value), Value::class)
);
}

Expand All @@ -58,7 +58,7 @@ public function reverseTransform($value)

if (!is_numeric($value)) {
throw new TransformationFailedException(
sprintf('Expected a numeric, got %s instead', gettype($value))
sprintf('Received %s instead of a numeric value', gettype($value))
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/FieldType/DataTransformer/DateValueTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function transform($value)

if (!$value instanceof Value) {
throw new TransformationFailedException(
sprintf('Expected a %s, got %s instead', Value::class, gettype($value))
sprintf('Received %s instead of %s', gettype($value), Value::class)
);
}

Expand All @@ -60,7 +60,7 @@ public function reverseTransform($value)

if (!is_numeric($value)) {
throw new TransformationFailedException(
sprintf('Expected a numeric, got %s instead', gettype($value))
sprintf('Received %s instead instead of a numeric value', gettype($value))
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/FieldType/DataTransformer/ImageAssetValueTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function transform($value): ?array

if (!$value instanceof Value) {
throw new TransformationFailedException(
sprintf('Expected a %s, got %s instead', Value::class, gettype($value))
sprintf('Received %s instead of %s', gettype($value), Value::class)
);
}

Expand Down Expand Up @@ -57,7 +57,7 @@ public function reverseTransform($value): ?Value

if (!is_array($value)) {
throw new TransformationFailedException(
sprintf('Expected a array, got %s instead', gettype($value))
sprintf('Received %s instead of an array', gettype($value))
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/FieldType/DataTransformer/TimeValueTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function reverseTransform($value)

if (!is_numeric($value)) {
throw new TransformationFailedException(
sprintf('Expected a numeric, got %s instead', gettype($value))
sprintf('Received %s instead of a numeric value', gettype($value))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function reverseTransform($value)

if (count($emptyFields) > 0) {
throw new TransformationFailedException(
sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields))
sprintf('Fields "%s" should not be empty', implode('", "', $emptyFields))
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Form/Processor/ContentFormProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private function resolveMainLanguageCode($data): string
if (!$data instanceof ContentUpdateData && !$data instanceof ContentCreateData) {
throw new InvalidArgumentException(
'$data',
'expected type of ContentUpdateData or ContentCreateData'
'Expected ContentUpdateData or ContentCreateData'
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Form/Processor/ContentTypeFormProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function processAddFieldDefinition(FormActionEvent $event)
if ($contentTypeDraft->mainLanguageCode !== $targetLanguageCode) {
throw new InvalidArgumentException(
'languageCode',
'FieldDefinitions can be only added to main language translation'
'Field definitions can only be added to the main language translation'
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Limitation/Mapper/ContentTypeLimitationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function mapLimitationValue(Limitation $limitation)
try {
$values[] = $this->contentTypeService->loadContentType($contentTypeId);
} catch (NotFoundException $e) {
$this->logger->error(sprintf('Could not map limitation value: Content Type with id = %s not found', $contentTypeId));
$this->logger->error(sprintf('Could not map the Limitation value: could not find a Content Type with ID %s', $contentTypeId));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Limitation/Mapper/LanguageLimitationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function mapLimitationValue(Limitation $limitation)
try {
$values[] = $this->languageService->loadLanguage($languageCode);
} catch (NotFoundException $e) {
$this->logger->error(sprintf('Could not map limitation value: Language with code = %s not found', $languageCode));
$this->logger->error(sprintf('Could not map the Limitation value: could not find a language with code %s', $languageCode));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Limitation/Mapper/ObjectStateLimitationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function mapLimitationValue(Limitation $limitation)
$this->objectStateService->loadObjectState($stateId)
);
} catch (NotFoundException $e) {
$this->logger->error(sprintf('Could not map limitation value: ObjectState with id = %s not found', $stateId));
$this->logger->error(sprintf('Could not map the Limitation value: could not find an Object state with ID %s', $stateId));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Limitation/Mapper/SectionLimitationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function mapLimitationValue(Limitation $limitation)
try {
$values[] = $this->sectionService->loadSection($sectionId);
} catch (NotFoundException $e) {
$this->logger->error(sprintf('Could not map limitation value: Section with id = %s not found', $sectionId));
$this->logger->error(sprintf('Could not map the Limitation value: could not find a Section with ID %s', $sectionId));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Limitation/Templating/LimitationBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function renderLimitationValue(Limitation $limitation, array $parameters

$template = $this->findTemplateWithBlock($blockName, $localTemplate);
if ($template === null) {
throw new MissingLimitationBlockException("Could not find block for {$limitation->getIdentifier()}: $blockName!");
throw new MissingLimitationBlockException("Could not find a block for {$limitation->getIdentifier()}: $blockName.");
}

return $template->renderBlock($blockName, $parameters);
Expand Down
2 changes: 1 addition & 1 deletion lib/User/ConfigurableSudoRepositoryLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function setParam($name, $value)
protected function getParam($name)
{
if (!isset($this->params[$name])) {
throw new OutOfBoundsException("No such param '$name'");
throw new OutOfBoundsException("There is no param '$name'");
}

return $this->params[$name];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testMapLimitationValueWithNotExistingContentType()
$this->logger
->expects($this->once())
->method('error')
->with('Could not map limitation value: Content Type with id = foo not found');
->with('Could not map the Limitation value: could not find a Content Type with ID foo');

$actual = $this->mapper->mapLimitationValue(new ContentTypeLimitation([
'limitationValues' => $values,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testMapLimitationValueWithNotExistingContentType()
$this->logger
->expects($this->once())
->method('error')
->with('Could not map limitation value: Language with code = foo not found');
->with('Could not map the Limitation value: could not find a language with code foo');

$actual = $this->mapper->mapLimitationValue(new LanguageLimitation([
'limitationValues' => $values,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testMapLimitationValueWithNotExistingObjectState()
$this->logger
->expects($this->once())
->method('error')
->with('Could not map limitation value: ObjectState with id = foo not found');
->with('Could not map the Limitation value: could not find an Object state with ID foo');

$actual = $this->mapper->mapLimitationValue(new ObjectStateLimitation([
'limitationValues' => $values,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testMapLimitationValueWithNotExistingContentType()
$this->logger
->expects($this->once())
->method('error')
->with('Could not map limitation value: Section with id = foo not found');
->with('Could not map the Limitation value: could not find a Section with ID foo');

$actual = $this->mapper->mapLimitationValue(new SectionLimitation([
'limitationValues' => $values,
Expand Down

0 comments on commit 59f1efa

Please sign in to comment.