Improve error handling in connectDevice function to provide user-friendly messages for connection failures
This commit is contained in:
@@ -124,7 +124,10 @@ async function connectDevice() {
|
|||||||
// Log connection failure details
|
// Log connection failure details
|
||||||
await logCommunication(`Serial connection failed: ${error.message || 'Unknown error'}`, 'disconnected');
|
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();
|
closePort();
|
||||||
console.log("Closing port");
|
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.");
|
alert("System is still trying to close the serial port. If this message continues to come up please refresh this page.");
|
||||||
|
|||||||
Reference in New Issue
Block a user