diff --git a/function.php b/function.php index 2475f369..cd395769 100644 --- a/function.php +++ b/function.php @@ -896,6 +896,21 @@ if (!function_exists('trigger_print_error')) { } +if (!function_exists('println')) { + + /** + * @param mixed $message + * @param string $method + * @return bool + * @throws + */ + function println(mixed $message, string $method = 'app'): bool + { + return Kiri::getLogger()->failure($message, $method); + } +} + + if (!function_exists('event')) { diff --git a/kiri-engine/Abstracts/BaseApplication.php b/kiri-engine/Abstracts/BaseApplication.php index 82332b21..e7988b1a 100644 --- a/kiri-engine/Abstracts/BaseApplication.php +++ b/kiri-engine/Abstracts/BaseApplication.php @@ -158,6 +158,7 @@ abstract class BaseApplication extends Component /** * @param $id * @param $definition + * @throws Exception */ public function set($id, $definition): void { diff --git a/kiri-engine/Redis/Redis.php b/kiri-engine/Redis/Redis.php index 4020d188..5562d964 100644 --- a/kiri-engine/Redis/Redis.php +++ b/kiri-engine/Redis/Redis.php @@ -13,6 +13,7 @@ use Exception; use Kiri; use Kiri\Exception\RedisConnectException; use Kiri\Pool\Pool; +use function println; /** * Class Redis @@ -72,11 +73,10 @@ class Redis public function __call($name, $arguments): mixed { if (method_exists($this, $name)) { - $data = $this->{$name}(...$arguments); + return $this->{$name}(...$arguments); } else { - $data = $this->proxy($name, $arguments); + return $this->proxy($name, $arguments); } - return $data; } @@ -150,12 +150,12 @@ SCRIPT; { $client = $this->getClient(); try { - $response = $client->{$name}(...$arguments); + return $client->{$name}(...$arguments); } catch (\Throwable $throwable) { - $response = trigger_print_error($throwable, 'redis'); + return trigger_print_error(throwable($throwable)); + } finally { + $this->pool()->push($this->host, $client); } - $this->pool()->push($this->host, $client); - return $response; }