diff --git a/application/Espo/Core/Api/RequestProcessor.php b/application/Espo/Core/Api/RequestProcessor.php index f01064c5a4..504e031e0c 100644 --- a/application/Espo/Core/Api/RequestProcessor.php +++ b/application/Espo/Core/Api/RequestProcessor.php @@ -29,7 +29,7 @@ namespace Espo\Core\Api; -use Espo\Core\Exceptions\Error; +use Espo\Core\Exceptions\BadRequest; use Espo\Core\Authentication\AuthenticationFactory; use Espo\Core\Utils\Config; use Espo\Core\Utils\Log; @@ -116,7 +116,7 @@ class RequestProcessor /** * @throws \Espo\Core\Exceptions\NotFound - * @throws Error + * @throws BadRequest */ private function proceed(Request $request, Response $response): void { @@ -134,7 +134,7 @@ class RequestProcessor $actionName = $crudList[$httpMethod] ?? null; if (!$actionName) { - throw new Error("No action for method {$httpMethod}."); + throw new BadRequest("No action for method {$httpMethod}."); } } diff --git a/application/Espo/Core/ApplicationRunners/PortalClient.php b/application/Espo/Core/ApplicationRunners/PortalClient.php index 634b251b8b..3d32473f3a 100644 --- a/application/Espo/Core/ApplicationRunners/PortalClient.php +++ b/application/Espo/Core/ApplicationRunners/PortalClient.php @@ -29,11 +29,10 @@ namespace Espo\Core\ApplicationRunners; -use Espo\Core\Exceptions\Error; - use Espo\Core\{ Application\RunnerParameterized, Application\Runner\Params, + Exceptions\BadRequest, Exceptions\NotFound, Utils\ClientManager, Utils\Config, @@ -42,8 +41,7 @@ use Espo\Core\{ Portal\Utils\Url, Api\ErrorOutput, Api\RequestWrapper, - Api\ResponseWrapper, -}; + Api\ResponseWrapper}; use Slim\{ ResponseEmitter, @@ -89,7 +87,7 @@ class PortalClient implements RunnerParameterized $responseWrapped = new ResponseWrapper(new Response()); if ($requestWrapped->getMethod() !== 'GET') { - throw new Error("Only GET request is allowed."); + throw new BadRequest("Only GET request is allowed."); } try { diff --git a/application/Espo/Core/ApplicationUser.php b/application/Espo/Core/ApplicationUser.php index e7b166bd71..5b38a127ba 100644 --- a/application/Espo/Core/ApplicationUser.php +++ b/application/Espo/Core/ApplicationUser.php @@ -29,10 +29,6 @@ namespace Espo\Core; -use Espo\Core\Exceptions\{ - Error, -}; - use Espo\Entities\{ User, }; @@ -41,6 +37,8 @@ use Espo\Core\{ ORM\EntityManagerProxy, }; +use RuntimeException; + /** * Setting a current user for the application. */ @@ -57,15 +55,14 @@ class ApplicationUser } /** - * Setup the system user as a current user. The system user is used when no user is logged in. - * @throws Error + * Set up the system user as a current user. The system user is used when no user is logged in. */ public function setupSystemUser(): void { $user = $this->entityManagerProxy->getEntity('User', 'system'); if (!$user) { - throw new Error("System user is not found."); + throw new RuntimeException("System user is not found."); } $user->set('ipAddress', $_SERVER['REMOTE_ADDR'] ?? null); diff --git a/application/Espo/Core/Authentication/TwoFactor/LoginFactory.php b/application/Espo/Core/Authentication/TwoFactor/LoginFactory.php index fecae6144b..6750b05d61 100644 --- a/application/Espo/Core/Authentication/TwoFactor/LoginFactory.php +++ b/application/Espo/Core/Authentication/TwoFactor/LoginFactory.php @@ -31,7 +31,8 @@ namespace Espo\Core\Authentication\TwoFactor; use Espo\Core\InjectableFactory; use Espo\Core\Utils\Metadata; -use Espo\Core\Exceptions\Error; + +use LogicException; class LoginFactory { @@ -51,7 +52,7 @@ class LoginFactory $className = $this->metadata->get(['app', 'authentication2FAMethods', $method, 'loginClassName']); if (!$className) { - throw new Error("No login-class class for '{$method}'."); + throw new LogicException("No login-class class for '{$method}'."); } return $this->injectableFactory->create($className); diff --git a/application/Espo/Core/EntryPoint/Starter.php b/application/Espo/Core/EntryPoint/Starter.php index 4e1e217397..aeee9c11ae 100644 --- a/application/Espo/Core/EntryPoint/Starter.php +++ b/application/Espo/Core/EntryPoint/Starter.php @@ -29,7 +29,7 @@ namespace Espo\Core\EntryPoint; -use Espo\Core\Exceptions\Error; +use Espo\Core\Exceptions\BadRequest; use Espo\Core\Application\Runner\Params as RunnerParams; use Espo\Core\EntryPoint\EntryPointManager; use Espo\Core\ApplicationUser; @@ -87,6 +87,10 @@ class Starter $this->errorOutput = $errorOutput; } + /** + * @throws BadRequest + * @throws \Espo\Core\Exceptions\NotFound + */ public function start(?string $entryPoint = null, bool $final = false): void { $requestWrapped = new RequestWrapper( @@ -95,7 +99,7 @@ class Starter ); if ($requestWrapped->getMethod() !== 'GET') { - throw new Error("Only GET requests allowed for entry points."); + throw new BadRequest("Only GET requests allowed for entry points."); } if ($entryPoint === null) { @@ -103,7 +107,7 @@ class Starter } if (!$entryPoint) { - throw new Error("No 'entryPoint' param."); + throw new BadRequest("No 'entryPoint' param."); } $authRequired = $this->entryPointManager->checkAuthRequired($entryPoint); @@ -154,6 +158,9 @@ class Starter } } + /** + * @throws \Espo\Core\Exceptions\NotFound + */ private function processRequestInternal( string $entryPoint, RequestWrapper $request, diff --git a/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php b/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php index a65844582c..a2cb697bdd 100644 --- a/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php +++ b/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php @@ -30,7 +30,6 @@ namespace Espo\Core\FileStorage\Storages; use Espo\Core\{ - Exceptions\Error, Utils\File\Manager as FileManager, FileStorage\Storage, FileStorage\Local, @@ -39,6 +38,8 @@ use Espo\Core\{ use Psr\Http\Message\StreamInterface; +use Espo\Core\Utils\File\Exceptions\FileError; + use GuzzleHttp\Psr7\Stream; class EspoUploadDir implements Storage, Local @@ -71,7 +72,7 @@ class EspoUploadDir implements Storage, Local $filePath = $this->getFilePath($attachment); if (!$this->exists($attachment)) { - throw new Error("Could not get size for non-existing file '{$filePath}'."); + throw new FileError("Could not get size for non-existing file '{$filePath}'."); } return $this->fileManager->getSize($filePath); @@ -82,16 +83,16 @@ class EspoUploadDir implements Storage, Local $filePath = $this->getFilePath($attachment); if (!$this->exists($attachment)) { - throw new Error("Could not get stream for non-existing '{$filePath}'."); + throw new FileError("Could not get stream for non-existing '{$filePath}'."); } - $resouce = fopen($filePath, 'r'); + $resource = fopen($filePath, 'r'); - if ($resouce === false) { - throw new Error("Could not open '{$filePath}'."); + if ($resource === false) { + throw new FileError("Could not open '{$filePath}'."); } - return new Stream($resouce); + return new Stream($resource); } public function putStream(Attachment $attachment, StreamInterface $stream): void @@ -103,7 +104,7 @@ class EspoUploadDir implements Storage, Local $result = $this->fileManager->putContents($filePath, $contents); if (!$result) { - throw new Error("Could not store a file '{$filePath}'."); + throw new FileError("Could not store a file '{$filePath}'."); } } diff --git a/application/Espo/Core/Mail/Account/Fetcher.php b/application/Espo/Core/Mail/Account/Fetcher.php index 4f7ae25910..031b76b8c7 100644 --- a/application/Espo/Core/Mail/Account/Fetcher.php +++ b/application/Espo/Core/Mail/Account/Fetcher.php @@ -92,6 +92,9 @@ class Fetcher $this->afterFetchHook = $afterFetchHook; } + /** + * @throws Error + */ public function fetch(Account $account): void { if (!$account->isAvailableForFetching()) { @@ -236,6 +239,7 @@ class Fetcher /** * @return int[] + * @throws Error */ private function getIdList( Account $account, diff --git a/application/Espo/Core/Mail/Account/GroupAccount/Service.php b/application/Espo/Core/Mail/Account/GroupAccount/Service.php index f05629a6e1..b631944a52 100644 --- a/application/Espo/Core/Mail/Account/GroupAccount/Service.php +++ b/application/Espo/Core/Mail/Account/GroupAccount/Service.php @@ -112,6 +112,7 @@ class Service /** * @param string $id Account ID. + * @throws Error */ public function storeSentMessage(string $id, Message $message): void { diff --git a/application/Espo/Core/Mail/Account/PersonalAccount/Account.php b/application/Espo/Core/Mail/Account/PersonalAccount/Account.php index d4ac03c29a..3db9180198 100644 --- a/application/Espo/Core/Mail/Account/PersonalAccount/Account.php +++ b/application/Espo/Core/Mail/Account/PersonalAccount/Account.php @@ -58,6 +58,9 @@ class Account implements AccountInterface private const PORTION_LIMIT = 10; + /** + * @throws Error + */ public function __construct(EmailAccount $entity, EntityManager $entityManager, Config $config) { $this->entity = $entity; diff --git a/application/Espo/Core/Mail/Account/PersonalAccount/AccountFactory.php b/application/Espo/Core/Mail/Account/PersonalAccount/AccountFactory.php index eaf79e6148..5edd131de8 100644 --- a/application/Espo/Core/Mail/Account/PersonalAccount/AccountFactory.php +++ b/application/Espo/Core/Mail/Account/PersonalAccount/AccountFactory.php @@ -49,6 +49,9 @@ class AccountFactory $this->entityManager = $entityManager; } + /** + * @throws Error + */ public function create(string $id): Account { $entity = $this->entityManager->getEntityById(EmailAccount::ENTITY_TYPE, $id); diff --git a/application/Espo/Core/Mail/Account/PersonalAccount/Service.php b/application/Espo/Core/Mail/Account/PersonalAccount/Service.php index c1e5036f93..f44a6e54e2 100644 --- a/application/Espo/Core/Mail/Account/PersonalAccount/Service.php +++ b/application/Espo/Core/Mail/Account/PersonalAccount/Service.php @@ -150,6 +150,7 @@ class Service /** * @param string $id Account ID. + * @throws Error */ public function storeSentMessage(string $id, Message $message): void { diff --git a/application/Espo/Core/Mail/Sender.php b/application/Espo/Core/Mail/Sender.php index b347759777..a1d124cbe2 100644 --- a/application/Espo/Core/Mail/Sender.php +++ b/application/Espo/Core/Mail/Sender.php @@ -430,6 +430,7 @@ class Sender * @param ?array $params @deprecated * @param ?Message $message @deprecated * @param iterable<\Espo\Entities\Attachment> $attachmentList @deprecated + * @throws Error */ public function send( Email $email, @@ -686,7 +687,7 @@ class Sender $email->set('messageId', '<' . $messageId . '>'); - if ($email->id) { + if ($email->hasId()) { $this->entityManager->saveEntity($email, ['silent' => true]); } } @@ -712,14 +713,16 @@ class Sender $this->useGlobal(); $this->handleException($e); - - return; } $this->resetParams(); $this->useGlobal(); } + /** + * @throws Error + * @return never + */ private function handleException(Exception $e): void { if ($e instanceof ProtocolRuntimeException) { diff --git a/application/Espo/Core/Record/ServiceFactory.php b/application/Espo/Core/Record/ServiceFactory.php index bb46e77987..d4a745ea93 100644 --- a/application/Espo/Core/Record/ServiceFactory.php +++ b/application/Espo/Core/Record/ServiceFactory.php @@ -29,7 +29,6 @@ namespace Espo\Core\Record; -use Espo\Core\Exceptions\Error; use Espo\Core\ServiceFactory as Factory; use Espo\Core\Utils\Metadata; @@ -113,7 +112,7 @@ class ServiceFactory public function createInternal(string $entityType): Service { if (!$this->metadata->get(['scopes', $entityType, 'entity'])) { - throw new Error("Can't create record service '{$entityType}', there's no such entity type."); + throw new RuntimeException("Can't create record service '{$entityType}', there's no such entity type."); } if (!$this->serviceFactory->checkExists($entityType)) { diff --git a/application/Espo/Core/Utils/DataUtil.php b/application/Espo/Core/Utils/DataUtil.php index a02ec84b93..86bbb5bba2 100644 --- a/application/Espo/Core/Utils/DataUtil.php +++ b/application/Espo/Core/Utils/DataUtil.php @@ -29,9 +29,8 @@ namespace Espo\Core\Utils; -use Espo\Core\Exceptions\Error; - use InvalidArgumentException; +use LogicException; class DataUtil { @@ -39,8 +38,6 @@ class DataUtil * @param array $data * @param array|string $unsetList * @return array - * @throws InvalidArgumentException - * @throws Error */ public static function unsetByKey(&$data, $unsetList, bool $removeEmptyItems = false) { @@ -63,7 +60,7 @@ class DataUtil $arr = explode('.', $unsetItem); } else { - throw new Error('Bad unset parameter'); + throw new LogicException('Bad unset parameter'); } $pointer = &$data; diff --git a/application/Espo/Core/Utils/Language.php b/application/Espo/Core/Utils/Language.php index b719ee23cc..33ad41d26b 100644 --- a/application/Espo/Core/Utils/Language.php +++ b/application/Espo/Core/Utils/Language.php @@ -30,17 +30,15 @@ namespace Espo\Core\Utils; use Espo\Core\{ - Exceptions\Error, - Utils\Util, Utils\File\Manager as FileManager, - Utils\Config, - Utils\DataCache, Utils\Resource\Reader as ResourceReader, Utils\Resource\Reader\Params as ResourceReaderParams, }; use Espo\Entities\Preferences; +use RuntimeException; + class Language { /** @@ -230,14 +228,13 @@ class Language * @param string|string[]|null $key * @param mixed $returns * @return mixed - * @throws Error */ public function get($key = null, $returns = null) { $data = $this->getData(); if (!isset($data)) { - throw new Error('Language: current language '.$this->currentLanguage.' not found'); + throw new RuntimeException('Language: current language '.$this->currentLanguage.' not found'); } return Util::getValueByKey($data, $key, $returns); diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php index 30946fc829..232c568495 100644 --- a/application/Espo/Core/Utils/Metadata.php +++ b/application/Espo/Core/Utils/Metadata.php @@ -30,16 +30,15 @@ namespace Espo\Core\Utils; use Espo\Core\{ - Exceptions\Error, Utils\File\Manager as FileManager, - Utils\Module, Utils\Metadata\Helper, - Utils\DataCache, Utils\Resource\Reader as ResourceReader, Utils\Resource\Reader\Params as ResourceReaderParams, }; use stdClass; +use LogicException; +use RuntimeException; /** * Application metadata. @@ -159,9 +158,7 @@ class Metadata */ public function get($key = null, $default = null) { - $result = Util::getValueByKey($this->getData(), $key, $default); - - return $result; + return Util::getValueByKey($this->getData(), $key, $default); } /** @@ -575,7 +572,7 @@ class Metadata $rowResult = $this->fileManager->unsetJsonContents($filePath, $unsetData); if (!$rowResult) { - throw new Error( + throw new LogicException( "Metadata items {$key1}.{$key2} can be deleted for custom code only." ); } @@ -586,7 +583,7 @@ class Metadata } if (!$result) { - throw new Error("Error while saving metadata. See log file for details."); + throw new RuntimeException("Error while saving metadata. See log file for details."); } $this->clearChanges(); diff --git a/application/Espo/Core/Utils/PasswordHash.php b/application/Espo/Core/Utils/PasswordHash.php index b17860e29c..9232d37aec 100644 --- a/application/Espo/Core/Utils/PasswordHash.php +++ b/application/Espo/Core/Utils/PasswordHash.php @@ -29,7 +29,7 @@ namespace Espo\Core\Utils; -use Espo\Core\Exceptions\Error; +use RuntimeException; class PasswordHash { @@ -69,7 +69,7 @@ class PasswordHash $salt = $this->config->get('passwordSalt'); if (!isset($salt)) { - throw new Error('Option "passwordSalt" does not exist in config.php'); + throw new RuntimeException('Option "passwordSalt" does not exist in config.php'); } return $this->normalizeSalt($salt); diff --git a/application/Espo/Core/WebSocket/SenderFactory.php b/application/Espo/Core/WebSocket/SenderFactory.php index fc15c188da..6064552443 100644 --- a/application/Espo/Core/WebSocket/SenderFactory.php +++ b/application/Espo/Core/WebSocket/SenderFactory.php @@ -33,7 +33,8 @@ use Espo\Core\InjectableFactory; use Espo\Core\Utils\Config; use Espo\Core\Utils\Metadata; use Espo\Core\Binding\Factory; -use Espo\Core\Exceptions\Error; + +use RuntimeException; class SenderFactory implements Factory { @@ -60,7 +61,7 @@ class SenderFactory implements Factory $className = $this->metadata->get(['app', 'webSocket', 'messagers', $messager, 'senderClassName']); if (!$className) { - throw new Error("No sender for messager '{$messager}'."); + throw new RuntimeException("No sender for messager '{$messager}'."); } return $this->injectableFactory->create($className); diff --git a/application/Espo/Core/WebSocket/SubscriberFactory.php b/application/Espo/Core/WebSocket/SubscriberFactory.php index 9514a9f4a3..12d64f6553 100644 --- a/application/Espo/Core/WebSocket/SubscriberFactory.php +++ b/application/Espo/Core/WebSocket/SubscriberFactory.php @@ -33,7 +33,8 @@ use Espo\Core\InjectableFactory; use Espo\Core\Utils\Config; use Espo\Core\Utils\Metadata; use Espo\Core\Binding\Factory; -use Espo\Core\Exceptions\Error; + +use RuntimeException; class SubscriberFactory implements Factory { @@ -60,7 +61,7 @@ class SubscriberFactory implements Factory $className = $this->metadata->get(['app', 'webSocket', 'messagers', $messager, 'subscriberClassName']); if (!$className) { - throw new Error("No subscriber for messager '{$messager}'."); + throw new RuntimeException("No subscriber for messager '{$messager}'."); } return $this->injectableFactory->create($className); diff --git a/application/Espo/Entities/EmailAddress.php b/application/Espo/Entities/EmailAddress.php index c860016d80..e5027f0bad 100644 --- a/application/Espo/Entities/EmailAddress.php +++ b/application/Espo/Entities/EmailAddress.php @@ -29,10 +29,10 @@ namespace Espo\Entities; -use Espo\Core\Exceptions\Error; - use Espo\Core\ORM\Entity; +use InvalidArgumentException; + class EmailAddress extends Entity { public const ENTITY_TYPE = 'EmailAddress'; @@ -44,7 +44,7 @@ class EmailAddress extends Entity protected function _setName($value) { if (empty($value)) { - throw new Error("Not valid email address '{$value}'"); + throw new InvalidArgumentException("Not valid email address '{$value}'"); } $this->setInContainer('name', $value); diff --git a/application/Espo/Entities/Export.php b/application/Espo/Entities/Export.php index b5d7f0dbe6..80ea1edcef 100644 --- a/application/Espo/Entities/Export.php +++ b/application/Espo/Entities/Export.php @@ -35,7 +35,7 @@ use Espo\Core\Field\Link; use Espo\Tools\Export\Params; -use Espo\Core\Exceptions\Error; +use RuntimeException; class Export extends Entity { @@ -54,7 +54,7 @@ class Export extends Entity $raw = $this->get('params'); if (!is_string($raw)) { - throw new Error("No 'params'."); + throw new RuntimeException("No 'params'."); } /** @var Params $params */ @@ -68,7 +68,7 @@ class Export extends Entity $value = $this->get('status'); if (!is_string($value)) { - throw new Error("No 'status'."); + throw new RuntimeException("No 'status'."); } return $value; @@ -90,7 +90,7 @@ class Export extends Entity $value = $this->getValueObject('createdAt'); if (!$value instanceof DateTime) { - throw new Error("No 'createdAt'."); + throw new RuntimeException("No 'createdAt'."); } return $value; @@ -101,7 +101,7 @@ class Export extends Entity $value = $this->getValueObject('createdBy'); if (!$value instanceof Link) { - throw new Error("No 'createdBy'."); + throw new RuntimeException("No 'createdBy'."); } return $value; diff --git a/application/Espo/Entities/MassAction.php b/application/Espo/Entities/MassAction.php index 047843cbce..b985d3fb3a 100644 --- a/application/Espo/Entities/MassAction.php +++ b/application/Espo/Entities/MassAction.php @@ -36,7 +36,7 @@ use Espo\Core\Field\Link; use Espo\Core\MassAction\Data; use Espo\Core\MassAction\Params; -use Espo\Core\Exceptions\Error; +use RuntimeException; use stdClass; @@ -57,7 +57,7 @@ class MassAction extends Entity $raw = $this->get('params'); if (!is_string($raw)) { - throw new Error("No 'params'."); + throw new RuntimeException("No 'params'."); } /** @var Params $params */ @@ -71,7 +71,7 @@ class MassAction extends Entity $raw = $this->get('data'); if (!$raw instanceof stdClass) { - throw new Error("No 'data'."); + throw new RuntimeException("No 'data'."); } return Data::fromRaw($raw); @@ -82,7 +82,7 @@ class MassAction extends Entity $value = $this->get('entityType'); if (!is_string($value)) { - throw new Error("No 'entityType'."); + throw new RuntimeException("No 'entityType'."); } return $value; @@ -93,7 +93,7 @@ class MassAction extends Entity $value = $this->get('action'); if (!is_string($value)) { - throw new Error("No 'action'."); + throw new RuntimeException("No 'action'."); } return $value; @@ -104,7 +104,7 @@ class MassAction extends Entity $value = $this->get('status'); if (!is_string($value)) { - throw new Error("No 'status'."); + throw new RuntimeException("No 'status'."); } return $value; @@ -120,7 +120,7 @@ class MassAction extends Entity $value = $this->getValueObject('createdAt'); if (!$value instanceof DateTime) { - throw new Error("No 'createdAt'."); + throw new RuntimeException("No 'createdAt'."); } return $value; @@ -131,7 +131,7 @@ class MassAction extends Entity $value = $this->getValueObject('createdBy'); if (!$value instanceof Link) { - throw new Error("No 'createdBy'."); + throw new RuntimeException("No 'createdBy'."); } return $value; diff --git a/application/Espo/Entities/PhoneNumber.php b/application/Espo/Entities/PhoneNumber.php index 2643ed5391..75f3045d10 100644 --- a/application/Espo/Entities/PhoneNumber.php +++ b/application/Espo/Entities/PhoneNumber.php @@ -29,7 +29,7 @@ namespace Espo\Entities; -use Espo\Core\Exceptions\Error; +use InvalidArgumentException; use Espo\Core\ORM\Entity; @@ -44,7 +44,7 @@ class PhoneNumber extends Entity protected function _setName($value) { if (empty($value)) { - throw new Error("Phone number can't be empty"); + throw new InvalidArgumentException("Phone number can't be empty"); } $this->setInContainer('name', $value); diff --git a/application/Espo/Repositories/ArrayValue.php b/application/Espo/Repositories/ArrayValue.php index d0e09bd582..cb359c6b8c 100644 --- a/application/Espo/Repositories/ArrayValue.php +++ b/application/Espo/Repositories/ArrayValue.php @@ -32,10 +32,10 @@ namespace Espo\Repositories; use Espo\Core\ORM\Entity as CoreEntity; use Espo\ORM\Entity; -use Espo\Core\{ - Exceptions\Error, - Repositories\Database, -}; +use Espo\Core\Repositories\Database; + +use RuntimeException; +use LogicException; /** * @extends Database<\Espo\Entities\ArrayValue> @@ -47,7 +47,7 @@ class ArrayValue extends Database public function storeEntityAttribute(CoreEntity $entity, string $attribute, bool $populateMode = false): void { if ($entity->getAttributeType($attribute) !== Entity::JSON_ARRAY) { - throw new Error("ArrayValue: Can't store non array attribute."); + throw new LogicException("ArrayValue: Can't store non array attribute."); } if ($entity->getAttributeType('notStorable')) { @@ -69,7 +69,7 @@ class ArrayValue extends Database } if (!is_array($valueList)) { - throw new Error("ArrayValue: Bad value passed to JSON_ARRAY attribute {$attribute}."); + throw new RuntimeException("ArrayValue: Bad value passed to JSON_ARRAY attribute {$attribute}."); } $valueList = array_unique($valueList); @@ -133,7 +133,7 @@ class ArrayValue extends Database public function deleteEntityAttribute(CoreEntity $entity, string $attribute): void { if (!$entity->hasId()) { - throw new Error("ArrayValue: Can't delete {$attribute} w/o id given."); + throw new LogicException("ArrayValue: Can't delete {$attribute} w/o id given."); } $this->entityManager->getTransactionManager()->start(); diff --git a/tests/unit/Espo/Core/Utils/PasswordHashTest.php b/tests/unit/Espo/Core/Utils/PasswordHashTest.php index 5e4837cd17..0a4389a8eb 100644 --- a/tests/unit/Espo/Core/Utils/PasswordHashTest.php +++ b/tests/unit/Espo/Core/Utils/PasswordHashTest.php @@ -83,7 +83,7 @@ class PasswordHashTest extends \PHPUnit\Framework\TestCase public function testGetSaltException() { - $this->expectException('\Espo\Core\Exceptions\Error'); + $this->expectException(\RuntimeException::class); $this->reflection->invokeMethod('getSalt'); }