diff --git a/BackupCommand.php b/BackupCommand.php index 6f007ac..ae2c415 100644 --- a/BackupCommand.php +++ b/BackupCommand.php @@ -111,7 +111,7 @@ class BackupCommand extends Command $output->write('dump data success'); } catch (\Throwable $throwable) { - $output->writeln($throwable->getMessage()); + $output->writeln(throwable($throwable)); } finally { return 1; } diff --git a/Command.php b/Command.php index 7aa1ce7..beb2302 100644 --- a/Command.php +++ b/Command.php @@ -211,7 +211,8 @@ class Command extends Component private function error(Throwable $throwable): bool { $message = $this->sql . '.' . json_encode($this->params, JSON_UNESCAPED_UNICODE); - return \Kiri::getLogger()->addError($message . $throwable->getMessage(), 'mysql'); + error($throwable, [$message]); + return addError($throwable->getMessage(), 'mysql'); } diff --git a/Db.php b/Db.php index ea60e5a..23e42c2 100644 --- a/Db.php +++ b/Db.php @@ -65,7 +65,8 @@ class Db implements ISqlBuilder try { $result = call_user_func($closure, ...$params); } catch (\Throwable $throwable) { - $result = logger()->addError($throwable->getMessage(), 'mysql'); + error($throwable); + $result = addError($throwable->getMessage(), 'mysql'); } finally { if ($result === false) { static::rollback(); diff --git a/Model.php b/Model.php index cecd9f4..e698c20 100644 --- a/Model.php +++ b/Model.php @@ -185,7 +185,7 @@ class Model extends Base\Model public static function inserts(array $data): bool { if (empty($data)) { - return error('Insert data empty.', 'mysql'); + return addError('Insert data empty.', 'mysql'); } return static::query()->insert($data); } diff --git a/Pagination.php b/Pagination.php index 9ef6043..5cf9a22 100644 --- a/Pagination.php +++ b/Pagination.php @@ -149,7 +149,7 @@ class Pagination extends Component try { call_user_func($this->_callback, $data, $param); } catch (\Throwable $exception) { - \Kiri::getLogger()->addError($exception, 'throwable'); + error($exception); } finally { $data = null; } @@ -179,7 +179,7 @@ class Pagination extends Component try { call_user_func($this->_callback, $data, $param); } catch (\Throwable $exception) { - \Kiri::getLogger()->addError($exception, 'throwable'); + error($exception); } }