From c4861c5efa9d5fc17eaeb47a3f71d52f464cf705 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 22 Mar 2021 09:16:45 +0200 Subject: [PATCH] fix exceptions --- application/Espo/ORM/Repository/RDBRelation.php | 8 ++++---- .../Espo/ORM/Repository/RDBRelationSelectBuilder.php | 1 - application/Espo/ORM/Repository/RDBRepository.php | 11 +++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/application/Espo/ORM/Repository/RDBRelation.php b/application/Espo/ORM/Repository/RDBRelation.php index 679d0f7977..f5fee27241 100644 --- a/application/Espo/ORM/Repository/RDBRelation.php +++ b/application/Espo/ORM/Repository/RDBRelation.php @@ -292,7 +292,7 @@ class RDBRelation protected function processCheckForeignEntity(Entity $entity) { if ($this->foreignEntityType && $this->foreignEntityType !== $entity->getEntityType()) { - throw new InvalidArgumentException("Entity type doesn't match an entity type of the relation."); + throw new RuntimeException("Entity type doesn't match an entity type of the relation."); } if (!$entity->id) { @@ -370,7 +370,7 @@ class RDBRelation } if ($id === '') { - throw new InvalidArgumentException(); + throw new RuntimeException(); } $seed = $this->entityManager->getEntityFactory()->create($this->foreignEntityType); @@ -389,7 +389,7 @@ class RDBRelation } if ($id === '') { - throw new InvalidArgumentException(); + throw new RuntimeException(); } $seed = $this->entityManager->getEntityFactory()->create($this->foreignEntityType); @@ -408,7 +408,7 @@ class RDBRelation } if ($id === '') { - throw new InvalidArgumentException(); + throw new RuntimeException(); } $seed = $this->entityManager->getEntityFactory()->create($this->foreignEntityType); diff --git a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php index 9ab27403c5..b87fa65db3 100644 --- a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php @@ -40,7 +40,6 @@ use Espo\ORM\{ }; use RuntimeException; -use BadMethodCallException; /** * Builds select parameters for related records for RDB repository. diff --git a/application/Espo/ORM/Repository/RDBRepository.php b/application/Espo/ORM/Repository/RDBRepository.php index 646da1014c..10f025ca84 100644 --- a/application/Espo/ORM/Repository/RDBRepository.php +++ b/application/Espo/ORM/Repository/RDBRepository.php @@ -41,7 +41,6 @@ use Espo\ORM\{ use StdClass; use RuntimeException; -use InvalidArgumentException; class RDBRepository extends Repository { @@ -232,7 +231,7 @@ class RDBRepository extends Repository $params = $params ?? []; if ($entity->getEntityType() !== $this->entityType) { - throw new InvalidArgumentException("Not supported entity type."); + throw new RuntimeException("Not supported entity type."); } if (!$entity->id) { @@ -283,7 +282,7 @@ class RDBRepository extends Repository $params = $params ?? []; if ($entity->getEntityType() !== $this->entityType) { - throw new InvalidArgumentException("Not supported entity type."); + throw new RuntimeException("Not supported entity type."); } if (!$entity->id) { @@ -373,7 +372,7 @@ class RDBRepository extends Repository } if ($entity->getEntityType() !== $this->entityType) { - throw new InvalidArgumentException("Not supported entity type."); + throw new RuntimeException("Not supported entity type."); } if ($foreign instanceof Entity) { @@ -421,7 +420,7 @@ class RDBRepository extends Repository } if ($entity->getEntityType() !== $this->entityType) { - throw new InvalidArgumentException("Not supported entity type."); + throw new RuntimeException("Not supported entity type."); } $this->beforeRelate($entity, $relationName, $foreign, $columnData, $options); @@ -478,7 +477,7 @@ class RDBRepository extends Repository } if ($entity->getEntityType() !== $this->entityType) { - throw new InvalidArgumentException("Not supported entity type."); + throw new RuntimeException("Not supported entity type."); } $this->beforeUnrelate($entity, $relationName, $foreign, $options);