Improve error handling in connectDevice function to provide user-friendly messages for connection failures

This commit is contained in:
“VeLiTi”
2026-01-29 19:31:41 +01:00
parent 0a4e145d57
commit 05aa5500e7

View File

@@ -124,7 +124,10 @@ async function connectDevice() {
// Log connection failure details
await logCommunication(`Serial connection failed: ${error.message || 'Unknown error'}`, 'disconnected');
if (openPort = 1){
// Check for specific "No port selected" error and show user-friendly message
if (error.message && error.message.includes('No port selected by the user')) {
progressBar("100", "No device selected, please try again", "#ff6666");
} else if (openPort === 1){
closePort();
console.log("Closing port");
alert("System is still trying to close the serial port. If this message continues to come up please refresh this page.");