Skip to content

Commit

Permalink
EZP-31021: Revise exception & command microcopy (#70)
Browse files Browse the repository at this point in the history
* EZP-31021: Revise exception & command microcopy

* Apply suggestions from code review

Co-Authored-By: MagdalenaZuba <[email protected]>

* Fix code style
  • Loading branch information
DominikaK authored and webhdx committed Dec 4, 2019
1 parent 8fe6ef2 commit 4eb8cf7
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/GraphQL/Mutation/UploadFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function createContent(array $mapping, UploadedFile $file, $locationId,
$valueType = FieldType\Media\Value::class;
break;
default:
throw new UserError('FieldType not supported for upload');
throw new UserError('Field Type does not support upload');
}
$struct->setField(
$mapping['contentFieldIdentifier'],
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Resolver/ContentThumbnailResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ private function getThumbnailImageField(Content $content): Field
}
}

throw new Exception("Content doesn't have an image compatible field");
throw new Exception('The Content item does not have an image-compatible Field');
}
}
20 changes: 10 additions & 10 deletions src/GraphQL/Resolver/DomainContentMutationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ public function updateDomainContent($input, Argument $args, $versionNo, $languag
} elseif (isset($args['contentId'])) {
$contentId = $args['contentId'];
} else {
throw new UserError('One argument out of id or contentId is required');
throw new UserError('Either id or contentId is required as an argument');
}

try {
$contentInfo = $this->getContentService()->loadContentInfo($contentId);
} catch (RepositoryExceptions\NotFoundException $e) {
throw new UserError("Content with id $contentId could not be loaded");
throw new UserError("Could not load content with ID $contentId");
} catch (RepositoryExceptions\UnauthorizedException $e) {
throw new UserError('You are not authorized to load this content');
}
try {
$contentType = $this->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
} catch (RepositoryExceptions\NotFoundException $e) {
throw new UserError("Content type with id $contentInfo->contentTypeId could not be loaded");
throw new UserError("Could not load Content Type with ID $contentInfo->contentTypeId");
}

$contentUpdateStruct = $this->getContentService()->newContentUpdateStruct();
Expand All @@ -89,13 +89,13 @@ public function updateDomainContent($input, Argument $args, $versionNo, $languag
try {
$versionInfo = $this->getContentService()->createContentDraft($contentInfo)->versionInfo;
} catch (RepositoryExceptions\UnauthorizedException $e) {
throw new UserError('You are not authorized to create a draft of this content');
throw new UserError('You are not authorized to create a draft of this Content item');
}
} else {
try {
$versionInfo = $this->getContentService()->loadVersionInfo($contentInfo, $versionNo);
} catch (RepositoryExceptions\NotFoundException $e) {
throw new UserError("Version $versionNo was not found");
throw new UserError("Could not find version $versionNo");
} catch (RepositoryExceptions\UnauthorizedException $e) {
throw new UserError('You are not authorized to load this version');
}
Expand All @@ -113,7 +113,7 @@ public function updateDomainContent($input, Argument $args, $versionNo, $languag
} catch (RepositoryExceptions\ContentFieldValidationException $e) {
throw new UserErrors($this->renderFieldValidationErrors($e, $contentType));
} catch (RepositoryExceptions\ContentValidationException $e) {
throw new UserError('The given input did not validate: ' . $e->getMessage());
throw new UserError('The provided input did not validate: ' . $e->getMessage());
} catch (RepositoryExceptions\UnauthorizedException $e) {
throw new UserError('You are not authorized to update this version');
}
Expand Down Expand Up @@ -178,15 +178,15 @@ public function deleteDomainContent(Argument $args)
} elseif (isset($args['contentId'])) {
$contentId = $args['contentId'];
} else {
throw new UserError('One argument out of id or contentId is required');
throw new UserError('Either id or contentId is required as an argument');
}

try {
$contentInfo = $this->getContentService()->loadContentInfo($contentId);
} catch (API\Exceptions\NotFoundException $e) {
throw new UserError("No content item was found with id $contentId");
throw new UserError("Could not find a Content item with ID $contentId");
} catch (API\Exceptions\UnauthorizedException $e) {
throw new UserError("You are not authorized to load the content item with id $contentId");
throw new UserError("You are not authorized to load the Content item with ID $contentId");
}
if (!isset($globalId)) {
$globalId = GlobalId::toGlobalId(
Expand All @@ -198,7 +198,7 @@ public function deleteDomainContent(Argument $args)
try {
$this->getContentService()->deleteContent($contentInfo);
} catch (API\Exceptions\UnauthorizedException $e) {
throw new UserError("You are not authorized to delete the content item with id $contentInfo->id");
throw new UserError("You are not authorized to delete the Content item with ID $contentInfo->id");
}

return [
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Resolver/ImageFieldResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function getImageField(ImageFieldValue $fieldValue): array
}

if (!$fieldFound) {
throw new UserError("No image field with ID $fieldId could be found");
throw new UserError("Could not find an image Field with ID $fieldId");
}

// check the field's value
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Resolver/ObjectStateGroupResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function resolveObjectStateGroupById(Argument $args): ObjectStateGroup
try {
return $this->objectStateService->loadObjectStateGroup($args['id']);
} catch (NotFoundException $e) {
throw new UserError("Object State Group with ID: {$args['id']} was not found.");
throw new UserError("Object state group with ID: {$args['id']} not found.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL/Resolver/ObjectStateResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function resolveObjectStateById(Argument $args): ObjectState
try {
return $this->objectStateService->loadObjectState($args['id']);
} catch (NotFoundException $e) {
throw new UserError("Object State with ID: {$args['id']} was not found.");
throw new UserError("Object state with ID: {$args['id']} not found.");
}
}

Expand All @@ -52,7 +52,7 @@ public function resolveObjectStatesByGroupId(Argument $args): array
try {
$group = $this->objectStateService->loadObjectStateGroup($args['groupId']);
} catch (NotFoundException $e) {
throw new UserError("Object State Group with ID: {$args['groupId']} was not found.");
throw new UserError("Object state group with ID: {$args['groupId']} not found.");
}

return $this->objectStateService->loadObjectStates($group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function work(Builder $schema, array $args)

$schema->addArgToField($this->groupName($args), $this->connectionField($args), new Input\Arg(
'sortBy', '[SortByOptions]',
['description' => 'A sort clause, or array of clauses. Add _desc after a clause to reverse it']
['description' => 'A Sort Clause, or array of Clauses. Add _desc after a Clause to reverse it']
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public function work(Builder $schema, array $args)

$schema->addArgToField($this->groupName($args), $this->typeField($args), new Input\Arg(
'id', 'Int',
['description' => sprintf('A %s content id', $contentType->identifier)]
['description' => sprintf('Content ID of the %s', $contentType->identifier)]
));

$schema->addArgToField($this->groupName($args), $this->typeField($args), new Input\Arg(
'remoteId', 'String',
['description' => sprintf('A %s content remote id', $contentType->identifier)]
['description' => sprintf('Content remote ID of the %s', $contentType->identifier)]
));

$schema->addArgToField($this->groupName($args), $this->typeField($args), new Input\Arg(
'locationId', 'Int',
['description' => sprintf('A %s content location id', $contentType->identifier)]
['description' => sprintf('Location ID of the %s', $contentType->identifier)]
));
}

Expand Down

0 comments on commit 4eb8cf7

Please sign in to comment.