From eec40d28a23b1b583a838925d87a2aa43a2ac304 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 17 Dec 2022 09:37:54 -0500 Subject: [PATCH] better? different? exception handler --- .../io/src/main/java/com/rusefi/io/CommandQueue.java | 6 +++++- java_console/ui/src/main/java/com/rusefi/ConsoleUI.java | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/java_console/io/src/main/java/com/rusefi/io/CommandQueue.java b/java_console/io/src/main/java/com/rusefi/io/CommandQueue.java index 367d6fe395..e204eb752f 100644 --- a/java_console/io/src/main/java/com/rusefi/io/CommandQueue.java +++ b/java_console/io/src/main/java/com/rusefi/io/CommandQueue.java @@ -1,6 +1,7 @@ package com.rusefi.io; import com.devexperts.logging.Logging; +import com.rusefi.Listener; import com.rusefi.config.generated.Fields; import com.rusefi.util.IoUtils; import org.jetbrains.annotations.NotNull; @@ -99,6 +100,8 @@ public class CommandQueue { } } + public static Listener ERROR_HANDLER = parameter -> IoUtils.exit("CommandQueue error: " + parameter, -2); + public CommandQueue(LinkManager linkManager) { this.linkManager = linkManager; runnable = new Runnable() { @@ -110,7 +113,8 @@ public class CommandQueue { try { sendPendingCommand(); } catch (Throwable e) { - IoUtils.exit("CommandQueue error" + e, -2); + log.error("Major connectivity error", e); + ERROR_HANDLER.onResult(e); } } } diff --git a/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java b/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java index aaa2ad7ea4..a050d69e9b 100644 --- a/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java +++ b/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java @@ -4,6 +4,7 @@ import com.devexperts.logging.Logging; import com.rusefi.autodetect.PortDetector; import com.rusefi.binaryprotocol.BinaryProtocolLogger; import com.rusefi.core.MessagesCentral; +import com.rusefi.io.CommandQueue; import com.rusefi.io.LinkManager; import com.rusefi.io.serial.BaudRateHolder; import com.rusefi.maintenance.FirmwareFlasher; @@ -62,6 +63,10 @@ public class ConsoleUI { } public ConsoleUI(String port) { + CommandQueue.ERROR_HANDLER = e -> SwingUtilities.invokeLater(() -> { + throw new IllegalStateException("Connectivity error", e); + }); + log.info("init..."); tabbedPane = new TabbedPanel(uiContext); this.port = port;