Skip to content

Commit

Permalink
fix(bridge): window call should catch error
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Dec 1, 2024
1 parent 605c3d6 commit 7bdf100
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/main/src/tipc/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const readerRoute = {
}

await tts.setMetadata(input, OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS).catch((error) => {
return callWindowExpose(window).toast.error(error.message, {
const msg = typeof error === "string" ? error : error.message
return callWindowExpose(window).toast.error(msg || "unknown set voice error", {
duration: 1000,
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function createProxy<T extends RenderGlobalContext>(window: BrowserWindow, path:

try {
return await window.webContents.executeJavaScript(
`globalThis.${PREFIX}?.${methodPath}?.(${args.map((arg) => JSON.stringify(arg)).join(",")})`,
`(async () => { try { return await globalThis.${PREFIX}?.${methodPath}?.(${args.map((arg) => JSON.stringify(arg)).join(",")}) } catch (err) { console.error('Failed to executeJavaScript: ${methodPath}', err) } })()`,
)
} catch (err) {
console.error(`Failed to executeJavaScript: ${methodPath}`, err)
Expand Down

0 comments on commit 7bdf100

Please sign in to comment.