From 8192bbf3dc681a1f5c2d9838df757e224c6dec27 Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Tue, 5 Nov 2024 09:56:43 -0300 Subject: [PATCH] Catch errors when `diskNavigationRoot` isn't valid --- ui/arduino/store.js | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index f008c4b..adb79d5 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -406,24 +406,36 @@ async function store(state, emitter) { emitter.emit('render') if (state.isConnected) { - state.boardFiles = await getBoardFiles( - serial.getFullPath( - state.boardNavigationRoot, - state.boardNavigationPath, - '' + try { + state.boardFiles = await getBoardFiles( + serial.getFullPath( + state.boardNavigationRoot, + state.boardNavigationPath, + '' + ) ) - ) + } catch (e) { + state.boardFiles = [] + } } else { state.boardFiles = [] } - state.diskFiles = await getDiskFiles( - disk.getFullPath( - state.diskNavigationRoot, - state.diskNavigationPath, - '' + try { + state.diskFiles = await getDiskFiles( + disk.getFullPath( + state.diskNavigationRoot, + state.diskNavigationPath, + '' + ) ) - ) + } catch (e) { + state.diskNavigationRoot = null + state.diskNavigationPath = '/' + state.isLoadingFiles = false + emitter.emit('render') + return + } emitter.emit('refresh-selected-files') state.isLoadingFiles = false