summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRikki <i@rikki.moe>2025-04-19 16:58:13 +0800
committerRikki <i@rikki.moe>2025-04-19 16:58:13 +0800
commit3e0f7d661fcc0c7edde60bb68554a97f2260c7ff (patch)
tree784e1c86d32f9c9f47262aefc16c224dcb90c33c
parent57e744784e28618ec9a00c3500dd2d509f14f3a1 (diff)
handle error properly
-rw-r--r--scripts/main.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/main.js b/scripts/main.js
index 8f62173..443959f 100644
--- a/scripts/main.js
+++ b/scripts/main.js
@@ -116,6 +116,7 @@ async function playSound(file, speed = 1, loops = 1) {
// return _playWithAudioElement(file, speed, loops);
console.error('❌ Failed to play sound:', err);
+ return Promise.reject(err);
}
}
@@ -353,7 +354,13 @@ async function showOutput(command, args) {
trueValue(command);
createText('Oiia is coming...');
const iv = setInterval(() => createText('Oiia! Oiia! Oiia!'), 700);
- await playSound('/static/oiia-short.mp3', Math.random() + 1, 2);
+ // playSound and check if error
+ try {
+ await playSound('/static/oiia-short.mp3', Math.random() + 0.5, 2);
+ } catch (err) {
+ createErrorText('Failed to play sound: ' + err.message);
+ }
+
clearInterval(iv);
break;
case 'email':