exception changes

This commit is contained in:
Yuri Kuznetsov
2022-06-23 14:03:04 +03:00
parent 2d12868849
commit 459de7be6f
25 changed files with 95 additions and 84 deletions

View File

@@ -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);