Merge pull request #280 from ruansheng8/fix-unwrapEx

修复使用Mappers执行语法时, 异常未被精确抛出问题
This commit is contained in:
Michael Yang 2024-02-21 12:02:01 +08:00 committed by GitHub
commit 23624147d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,6 +18,7 @@ package com.mybatisflex.core.mybatis;
import com.mybatisflex.core.BaseMapper; import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.FlexGlobalConfig; import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.exception.FlexExceptions; import com.mybatisflex.core.exception.FlexExceptions;
import org.apache.ibatis.reflection.ExceptionUtil;
import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
@ -108,6 +109,8 @@ public class Mappers {
try (SqlSession sqlSession = openSession()) { try (SqlSession sqlSession = openSession()) {
Object mapper = sqlSession.getMapper(mapperClass); Object mapper = sqlSession.getMapper(mapperClass);
return method.invoke(mapper, args); return method.invoke(mapper, args);
} catch (Throwable throwable) {
throw ExceptionUtil.unwrapThrowable(throwable);
} }
} }