Skip to content

Commit e606e60

Browse files
committed
wip improve exception messages
1 parent e73c318 commit e606e60

18 files changed

+97
-45
lines changed

src/EventListener/Neo4j/ConstraintCreateToStatementEventListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public static function constraintStatement(ConstraintInterface $constraint): Sta
4545
{
4646
$constraintName = $constraint->getConstraintName();
4747
if (null === $constraintName) {
48-
throw new InvalidArgumentException("constraint name can not be null");
48+
throw InvalidArgumentException::createForConstraintNameIsNull();
4949
}
5050
$elementIdentifier = '';
5151
$elementLabel = $constraint->getFor();
5252
if (null === $elementLabel) {
53-
throw new InvalidArgumentException("constraint for label/type can not be null");
53+
throw InvalidArgumentException::createForConstraintForIsNull();
5454
}
5555
if ($elementLabel instanceof NodeLabelInterface) {
5656
$elementIdentifier = '(e:'.((string) $elementLabel).')';
@@ -66,7 +66,7 @@ public static function constraintStatement(ConstraintInterface $constraint): Sta
6666
}
6767
$constraintType = $constraint->getConstraintType();
6868
if (null === $constraintType) {
69-
throw new InvalidArgumentException("constraint type can not be null");
69+
throw InvalidArgumentException::createForConstraintTypeIsNull();
7070
}
7171

7272
return new Statement(sprintf(

src/EventListener/Neo4j/ConstraintDeleteToStatementEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function constraintStatement(ConstraintInterface $constraint): Sta
4343
{
4444
$constraintName = $constraint->getConstraintName();
4545
if (null === $constraintName) {
46-
throw new InvalidArgumentException('constraint name can not be null when deleting a constraint');
46+
throw InvalidArgumentException::createForConstraintNameIsNull();
4747
}
4848

4949
return new Statement(sprintf(

src/EventListener/Neo4j/IndexCreateToStatementEventListener.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public static function indexStatement(IndexInterface $index): Statement
4747
$propertyIdentifier = '';
4848

4949
$indexType = $index->getIndexType();
50-
if (null === $indexType) {
51-
throw new InvalidArgumentException('index type can not be null when creating an index');
50+
if (!$indexType) {
51+
throw InvalidArgumentException::createForIndexTypeIsNull();
5252
}
5353

5454
$elementLabel = $index->getFor();
55-
if (null === $elementLabel) {
56-
throw new InvalidArgumentException("index for label/type can not be null");
55+
if (!$elementLabel) {
56+
throw InvalidArgumentException::createForIndexForIsNull();
5757
}
5858
if ($elementLabel instanceof NodeLabelInterface) {
5959
$elementIdentifier = '(e:'.((string) $elementLabel).')';

src/EventListener/Neo4j/IndexDeleteToStatementEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function indexStatement(IndexInterface $index): Statement
4343
{
4444
$indexName = $index->getIndexName();
4545
if (null === $indexName) {
46-
throw new InvalidArgumentException('index name can not be null when deleting an index');
46+
throw InvalidArgumentException::createForIndexNameIsNull();
4747
}
4848

4949
return new Statement(sprintf(

src/EventListener/OpenCypher/RelationCreateToStatementEventListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public static function relationStatement(RelationInterface $relation): Statement
5757
}
5858
$startNode = $relation->getStartNode();
5959
if (null === $startNode) {
60-
throw new InvalidArgumentException('the start node of relations can not be null');
60+
throw InvalidArgumentException::createForStartNodeIsNull();
6161
}
6262
$endNode = $relation->getEndNode();
6363
if (null === $endNode) {
64-
throw new InvalidArgumentException('the end node of relations can not be null');
64+
throw InvalidArgumentException::createForEndNodeIsNull();
6565
}
6666

6767
return new Statement(

src/EventListener/OpenCypher/RelationDeleteToStatementEventListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public static function relationStatement(RelationInterface $relation): Statement
4545
{
4646
$startNode = $relation->getStartNode();
4747
if (null === $startNode) {
48-
throw new InvalidArgumentException('the start node of relations can not be null');
48+
throw InvalidArgumentException::createForStartNodeIsNull();
4949
}
5050
$endNode = $relation->getEndNode();
5151
if (null === $endNode) {
52-
throw new InvalidArgumentException('the end node of relations can not be null');
52+
throw InvalidArgumentException::createForEndNodeIsNull();
5353
}
5454

5555
return new Statement(

src/EventListener/OpenCypher/RelationMergeToStatementEventListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public static function relationStatement(RelationInterface $relation): Statement
4545
{
4646
$startNode = $relation->getStartNode();
4747
if (null === $startNode) {
48-
throw new InvalidArgumentException('the start node of relations can not be null');
48+
throw InvalidArgumentException::createForStartNodeIsNull();
4949
}
5050
$endNode = $relation->getEndNode();
5151
if (null === $endNode) {
52-
throw new InvalidArgumentException('the end node of relations can not be null');
52+
throw InvalidArgumentException::createForEndNodeIsNull();
5353
}
5454

5555
return new Statement(

src/EventListener/OpenCypher/SimilarRelationQueueCreateToStatementEventListener.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
5353
$startNode = $relation->getStartNode();
5454
$endNode = $relation->getEndNode();
5555
if (!$startNode) {
56-
throw new InvalidArgumentException('start node of relations can not be null');
56+
throw InvalidArgumentException::createForStartNodeIsNull();
5757
}
5858
if (!$endNode) {
59-
throw new InvalidArgumentException('start node of relations can not be null');
59+
throw InvalidArgumentException::createForEndNodeIsNull();
6060
}
6161
if (!$firstRelation) {
6262
$firstRelation = $relation;
@@ -74,10 +74,14 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
7474
return StructureHelper::getEmptyStatement();
7575
}
7676
if (!$firstRelationStartNode) {
77-
throw new InvalidArgumentException('start node of relations can not be null');
77+
throw InvalidArgumentException::createForStartNodeIsNull();
7878
}
7979
if (!$firstRelationEndNode) {
80-
throw new InvalidArgumentException('end node of relations can not be null');
80+
throw InvalidArgumentException::createForEndNodeIsNull();
81+
}
82+
$relationType = $firstRelation->getRelationType();
83+
if (!$relationType) {
84+
throw InvalidArgumentException::createForRelationTypeIsNull();
8185
}
8286

8387
return new Statement(
@@ -92,7 +96,7 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
9296
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelationStartNode, 'row.startNodeIdentifier'),
9397
ToCypherHelper::nodeLabelStorageToCypherLabelString($firstRelationEndNode->getNodeLabels()),
9498
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelationEndNode, 'row.endNodeIdentifier'),
95-
(string) $firstRelation->getRelationType(),
99+
(string) $relationType,
96100
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelation, 'row.relationIdentifier')
97101
),
98102
[

src/EventListener/OpenCypher/SimilarRelationQueueDeleteToStatementEventListener.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
5353
$startNode = $relation->getStartNode();
5454
$endNode = $relation->getEndNode();
5555
if (!$startNode) {
56-
throw new InvalidArgumentException('start node of relations can not be null');
56+
throw InvalidArgumentException::createForStartNodeIsNull();
5757
}
5858
if (!$endNode) {
59-
throw new InvalidArgumentException('start node of relations can not be null');
59+
throw InvalidArgumentException::createForEndNodeIsNull();
6060
}
6161
if (!$firstRelation) {
6262
$firstRelation = $relation;
@@ -73,10 +73,14 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
7373
return StructureHelper::getEmptyStatement();
7474
}
7575
if (!$firstRelationStartNode) {
76-
throw new InvalidArgumentException('start node of relations can not be null');
76+
throw InvalidArgumentException::createForStartNodeIsNull();
7777
}
7878
if (!$firstRelationEndNode) {
79-
throw new InvalidArgumentException('end node of relations can not be null');
79+
throw InvalidArgumentException::createForEndNodeIsNull();
80+
}
81+
$relationType = $firstRelation->getRelationType();
82+
if (!$relationType) {
83+
throw InvalidArgumentException::createForRelationTypeIsNull();
8084
}
8185

8286
return new Statement(
@@ -86,7 +90,7 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
8690
"DELETE relation",
8791
ToCypherHelper::nodeLabelStorageToCypherLabelString($firstRelationStartNode->getNodeLabels()),
8892
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelationStartNode, 'row.startNodeIdentifier'),
89-
(string) $firstRelation->getRelationType(),
93+
(string) $relationType,
9094
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelation, 'row.relationIdentifier'),
9195
ToCypherHelper::nodeLabelStorageToCypherLabelString($firstRelationEndNode->getNodeLabels()),
9296
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelationEndNode, 'row.endNodeIdentifier'),

src/EventListener/OpenCypher/SimilarRelationQueueMergeToStatementEventListener.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
5353
$startNode = $relation->getStartNode();
5454
$endNode = $relation->getEndNode();
5555
if (!$startNode) {
56-
throw new InvalidArgumentException('start node of relations can not be null');
56+
throw InvalidArgumentException::createForStartNodeIsNull();
5757
}
5858
if (!$endNode) {
59-
throw new InvalidArgumentException('start node of relations can not be null');
59+
throw InvalidArgumentException::createForEndNodeIsNull();
6060
}
6161
if (!$firstRelation) {
6262
$firstRelation = $relation;
@@ -74,10 +74,14 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
7474
return StructureHelper::getEmptyStatement();
7575
}
7676
if (!$firstRelationStartNode) {
77-
throw new InvalidArgumentException('start node of relations can not be null');
77+
throw InvalidArgumentException::createForStartNodeIsNull();
7878
}
7979
if (!$firstRelationEndNode) {
80-
throw new InvalidArgumentException('end node of relations can not be null');
80+
throw InvalidArgumentException::createForEndNodeIsNull();
81+
}
82+
$relationType = $firstRelation->getRelationType();
83+
if (!$relationType) {
84+
throw InvalidArgumentException::createForRelationTypeIsNull();
8185
}
8286

8387
return new Statement(
@@ -92,7 +96,7 @@ public static function similarRelationQueueStatement(SimilarRelationQueueInterfa
9296
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelationStartNode, 'row.startNodeIdentifier'),
9397
ToCypherHelper::nodeLabelStorageToCypherLabelString($firstRelationEndNode->getNodeLabels()),
9498
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelationEndNode, 'row.endNodeIdentifier'),
95-
(string) $firstRelation->getRelationType(),
99+
(string) $relationType,
96100
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstRelation, 'row.relationIdentifier')
97101
),
98102
[

0 commit comments

Comments
 (0)