dbmsv4 init...5
This commit is contained in:
parent
7fb1408259
commit
9775453442
@ -34,11 +34,18 @@ abstract class CommonService
|
||||
final protected function dbTransaction(callable $callback, string $functionName = ''): mixed
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
try {
|
||||
$db->transException(true)->transStart();
|
||||
$result = $callback($db);
|
||||
$db->transComplete();
|
||||
return $result;
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
// ✅ 검증 에러는 감싸지 말고 그대로 던져야 Ajax가 422 + errors 받음
|
||||
$db->transRollback();
|
||||
throw $e;
|
||||
|
||||
} catch (DatabaseException $e) {
|
||||
$errorMessage = sprintf(
|
||||
"\n----[%s]에서 트랜잭션 실패: DB 오류----\n%s\n%s\n------------------------------\n",
|
||||
@ -48,8 +55,10 @@ abstract class CommonService
|
||||
);
|
||||
log_message('error', $errorMessage);
|
||||
throw new RuntimeException($errorMessage, $e->getCode(), $e);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
$db->transRollback();
|
||||
// ✅ 여기서 FormValidationException까지 RuntimeException으로 바뀌던게 문제였음
|
||||
throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user