exception changes
This commit is contained in:
@@ -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}.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}'.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -112,6 +112,7 @@ class Service
|
||||
|
||||
/**
|
||||
* @param string $id Account ID.
|
||||
* @throws Error
|
||||
*/
|
||||
public function storeSentMessage(string $id, Message $message): void
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -150,6 +150,7 @@ class Service
|
||||
|
||||
/**
|
||||
* @param string $id Account ID.
|
||||
* @throws Error
|
||||
*/
|
||||
public function storeSentMessage(string $id, Message $message): void
|
||||
{
|
||||
|
||||
@@ -430,6 +430,7 @@ class Sender
|
||||
* @param ?array<string,mixed> $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) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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<mixed,mixed> $data
|
||||
* @param array<int,string|string[]>|string $unsetList
|
||||
* @return array<mixed,mixed>
|
||||
* @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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user