Skip to content

Commit

Permalink
refactor: 트랜잭션 매니저에서 발생하는 SQL예외 처리방법 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
zillionme committed Oct 11, 2023
1 parent 8cf2002 commit 237a3a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.springframework.transaction.support;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.transaction.support.exception.TransactionException;

import javax.sql.DataSource;
import java.sql.Connection;
Expand Down Expand Up @@ -33,7 +33,7 @@ public <T> T executeWithResult(final Supplier<T> logicExecutor) {
return result;
} catch (Exception e) {
rollback(conn);
throw new DataAccessException(e);
throw new TransactionException(e);
} finally {
setTransactionInactive(conn);
DataSourceUtils.releaseConnection(conn, dataSource);
Expand All @@ -56,7 +56,7 @@ private void rollback(final Connection conn) {
try {
conn.rollback();
} catch (SQLException e) {
throw new DataAccessException(e);
throw new TransactionException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.springframework.transaction.support.exception;

public class TransactionException extends RuntimeException {
public TransactionException(final Exception e) {
}
}

0 comments on commit 237a3a3

Please sign in to comment.