From 4c19b72df823f4badc52bc395fbfe3b34b7d0448 Mon Sep 17 00:00:00 2001 From: makejava <1353036300@qq.com> Date: Thu, 27 Oct 2022 11:00:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D$tool.debug=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=96=B9=E6=B3=95=E5=8F=91=E7=94=9F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/sjhy/plugin/tool/GlobalTool.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sjhy/plugin/tool/GlobalTool.java b/src/main/java/com/sjhy/plugin/tool/GlobalTool.java index 36433f1..e489bf3 100644 --- a/src/main/java/com/sjhy/plugin/tool/GlobalTool.java +++ b/src/main/java/com/sjhy/plugin/tool/GlobalTool.java @@ -6,6 +6,8 @@ import com.intellij.util.ReflectionUtil; import com.sjhy.plugin.entity.DebugField; import com.sjhy.plugin.entity.DebugMethod; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -154,8 +156,15 @@ public class GlobalTool extends NameUtils { if (val != null) { debugMethod.setValue(val.toString()); } - } catch (IllegalAccessException | InvocationTargetException e) { - ExceptionUtil.rethrow(e); + } catch (IllegalAccessException e) { + // 忽略不允许访问异常 + } catch (Throwable e) { + // 其他任何异常都捕获 + ByteArrayOutputStream out = new ByteArrayOutputStream(); + PrintStream printStream = new PrintStream(new ByteArrayOutputStream()); + e.printStackTrace(printStream); + // 字节流的close方法本身就是空方法,没必要执行close操作 + debugMethod.setValue("调用发生异常:" + out); } } }