From 19eb0a2ae32a40365a9aa109f70e735c194f5397 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:11:22 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20fix:=20Replace=20empty=20catch?= =?UTF-8?q?=20blocks=20with=20descriptive=20error=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses empty catch blocks in `useAudio.js`, `App.jsx`, and `main.js` to improve maintainability and debugging by providing visibility into potential failures. - Added logging to `playAlarm` and `playPeep` in `src/hooks/useAudio.js`. - Added logging to sonic escalation hook in `src/App.jsx`. - Added logging to `get-logs` IPC handler in `electron/main.js`. Co-authored-by: BTawaifi <52285931+BTawaifi@users.noreply.github.com> --- electron/main.js | 4 +++- src/App.jsx | 4 +++- src/hooks/useAudio.js | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/electron/main.js b/electron/main.js index 740f3de..e1d60cb 100644 --- a/electron/main.js +++ b/electron/main.js @@ -169,7 +169,9 @@ ipcMain.handle('get-logs', async (event, customPath) => { const content = await fs.readFile(filePath, 'utf8'); return JSON.parse(content); } - } catch (e) { } + } catch (e) { + console.error("Failed to get logs:", e); + } return {}; }); diff --git a/src/App.jsx b/src/App.jsx index eeabdf7..1370caa 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -113,7 +113,9 @@ function App() { osc.onended = () => { osc.disconnect(); gain.disconnect(); audioCtx.close(); }; osc.start(audioCtx.currentTime); osc.stop(audioCtx.currentTime + dur); - } catch (e) { } + } catch (e) { + console.error("Sonic escalation failed:", e); + } }, [enforcementLevel, isEnforced, settings.enforcement?.soundCrescendo]); diff --git a/src/hooks/useAudio.js b/src/hooks/useAudio.js index 8b1afd4..f94685b 100644 --- a/src/hooks/useAudio.js +++ b/src/hooks/useAudio.js @@ -67,7 +67,9 @@ export const useAudio = (settings) => { oscillator.onended = () => { oscillator.disconnect(); gainNode.disconnect(); }; oscillator.start(audioCtx.currentTime); oscillator.stop(audioCtx.currentTime + 1); - } catch (e) { } + } catch (e) { + console.error("Audio failed (alarm):", e); + } }, [getAudioCtx]); const playPeep = useCallback((freq = 660, dur = 0.1) => { @@ -85,7 +87,9 @@ export const useAudio = (settings) => { oscillator.onended = () => { oscillator.disconnect(); gainNode.disconnect(); }; oscillator.start(audioCtx.currentTime); oscillator.stop(audioCtx.currentTime + dur); - } catch (e) { } + } catch (e) { + console.error("Audio failed (peep):", e); + } }, [getAudioCtx]); return {