Jeff Davidson
06/04/2021, 4:48 PMsuspend fun executeScript(frameId: Int): String {
val result = js("browser.tabs.executeScript({ frameId: frameId, code: 'window.location.href' })") as Promise<String>
return try {
result.await()
} catch (t: Throwable) {
// Never gets invoked
console.error("Got error in await:", t.message)
""
}
}
Jeff Davidson
06/04/2021, 4:49 PMPromise.reject(new Error('fail'))
then the catch block gets invoked. Also, I can capture the error by calling .catch() on the Promise. But shouldn't await() throw a Throwable that can be caught here, instead of just aborting execution and logging the error?Jeff Davidson
06/04/2021, 5:04 PMJeff Davidson
06/04/2021, 5:13 PMJeff Davidson
06/04/2021, 5:35 PM