Skip to content

Commit 236cdd7

Browse files
committed
ref: add more log in getDemoAudioData
ref #1184
1 parent 335f393 commit 236cdd7

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/preload/get-demo-audio-data.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,28 @@ type DemoAudioData = {
1212
};
1313

1414
export async function getDemoAudioData(checksum: string, audioFilePath: string): Promise<DemoAudioData | null> {
15-
const extension = path.parse(audioFilePath).ext.slice(1).toLowerCase();
16-
if (!supportedAudioExtensions.includes(extension)) {
17-
return null;
18-
}
19-
const fileExists = await pathExists(audioFilePath);
20-
if (!fileExists) {
21-
return null;
22-
}
15+
try {
16+
const extension = path.parse(audioFilePath).ext.slice(1).toLowerCase();
17+
if (!supportedAudioExtensions.includes(extension)) {
18+
return null;
19+
}
20+
const fileExists = await pathExists(audioFilePath);
21+
if (!fileExists) {
22+
return null;
23+
}
2324

24-
const offsetSeconds = getDemoAudioOffset(checksum);
25-
const [audio, bytes] = await Promise.all([loadAudio(audioFilePath), readFile(audioFilePath)]);
25+
const offsetSeconds = getDemoAudioOffset(checksum);
26+
const [audio, bytes] = await Promise.all([loadAudio(audioFilePath), readFile(audioFilePath)]);
2627

27-
return { audioFilePath, audio, audioBytes: bytes, offsetSeconds };
28+
return { audioFilePath, audio, audioBytes: bytes, offsetSeconds };
29+
} catch (error) {
30+
logger.error('Error loading demo audio data', audioFilePath);
31+
logger.error(error);
32+
if (error instanceof Error) {
33+
logger.error(error.name);
34+
logger.error(error.message);
35+
logger.error(error.stack);
36+
}
37+
throw error;
38+
}
2839
}

0 commit comments

Comments
 (0)