浏览代码

jfinal 3.6

James 7 年之前
父节点
当前提交
c40379453f
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/main/java/com/jfinal/plugin/activerecord/tx/Tx.java

+ 7 - 1
src/main/java/com/jfinal/plugin/activerecord/tx/Tx.java

@@ -81,7 +81,13 @@ public class Tx implements Interceptor {
 			LogKit.logNothing(e);
 		} catch (Throwable t) {
 			if (conn != null) try {conn.rollback();} catch (Exception e1) {LogKit.error(e1.getMessage(), e1);}
-			throw t instanceof RuntimeException ? (RuntimeException)t : new ActiveRecordException(t);
+			
+			// 支持在 controller 中 try catch 的 catch 块中使用 render(...) 并 throw e,实现灵活控制 render
+			if (inv.isActionInvocation() && inv.getController().getRender() != null) {
+				LogKit.error(t.getMessage(), t);
+			} else {
+				throw t instanceof RuntimeException ? (RuntimeException)t : new ActiveRecordException(t);
+			}
 		}
 		finally {
 			try {