From 9531d1e21b03d20747a8ed5b1f2f814f7f48cda7 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 22 Feb 2020 15:17:30 -0500 Subject: [PATCH] better (?) error handling --- java_console/logging/src/com/rusefi/FileLog.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/java_console/logging/src/com/rusefi/FileLog.java b/java_console/logging/src/com/rusefi/FileLog.java index d10fc6a3c4..d29607f5fc 100644 --- a/java_console/logging/src/com/rusefi/FileLog.java +++ b/java_console/logging/src/com/rusefi/FileLog.java @@ -3,6 +3,7 @@ package com.rusefi; import com.opensr5.Logger; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.io.*; import java.text.SimpleDateFormat; import java.util.Date; @@ -126,14 +127,18 @@ public enum FileLog { public void log(Throwable exception) { if (fileLog == null) - throw new NullPointerException("fileLog"); + throw new NullPointerException("fileLog while " + exception); OutputStreamWriter os = new OutputStreamWriter(fileLog); exception.printStackTrace(new PrintWriter(os)); } public void logException(String msg, Throwable e) { logLine(msg + e); - log(e); e.printStackTrace(); + if (fileLog == null) { + JOptionPane.showConfirmDialog(null, msg + " " + e, "no log and Exception Occurred", JOptionPane.DEFAULT_OPTION); + return; + } + log(e); } } \ No newline at end of file