This commit is contained in:
2023-04-18 23:47:30 +08:00
parent 7472217482
commit ebbc3368bd
5 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ class BackupCommand extends Command
$output->write('dump data success'); $output->write('dump data success');
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
$output->writeln($throwable->getMessage()); $output->writeln(throwable($throwable));
} finally { } finally {
return 1; return 1;
} }
+2 -1
View File
@@ -211,7 +211,8 @@ class Command extends Component
private function error(Throwable $throwable): bool private function error(Throwable $throwable): bool
{ {
$message = $this->sql . '.' . json_encode($this->params, JSON_UNESCAPED_UNICODE); $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');
} }
+2 -1
View File
@@ -65,7 +65,8 @@ class Db implements ISqlBuilder
try { try {
$result = call_user_func($closure, ...$params); $result = call_user_func($closure, ...$params);
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
$result = logger()->addError($throwable->getMessage(), 'mysql'); error($throwable);
$result = addError($throwable->getMessage(), 'mysql');
} finally { } finally {
if ($result === false) { if ($result === false) {
static::rollback(); static::rollback();
+1 -1
View File
@@ -185,7 +185,7 @@ class Model extends Base\Model
public static function inserts(array $data): bool public static function inserts(array $data): bool
{ {
if (empty($data)) { if (empty($data)) {
return error('Insert data empty.', 'mysql'); return addError('Insert data empty.', 'mysql');
} }
return static::query()->insert($data); return static::query()->insert($data);
} }
+2 -2
View File
@@ -149,7 +149,7 @@ class Pagination extends Component
try { try {
call_user_func($this->_callback, $data, $param); call_user_func($this->_callback, $data, $param);
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
\Kiri::getLogger()->addError($exception, 'throwable'); error($exception);
} finally { } finally {
$data = null; $data = null;
} }
@@ -179,7 +179,7 @@ class Pagination extends Component
try { try {
call_user_func($this->_callback, $data, $param); call_user_func($this->_callback, $data, $param);
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
\Kiri::getLogger()->addError($exception, 'throwable'); error($exception);
} }
} }