出现错误时不触发捕获 (Javascript)

Catch not triggering when there is an error (Javascript)

代码如下:

        try{
            document.getElementById("audioplayer").play()

        }
        catch {
            window.location.href = "https://vibify.fepzz.repl.co/get-song-redirect_name_download=" +  document.getElementById("error-catcher-link").innerHTML 
        }

这是一个在加载时调用的函数,每次调用它时我都会在 try 中收到错误,但由于某种原因 catch 块 catch 它没有。

对于遇到同样问题的人,我只需要使用

.play().catch(() => {
console.log("error playing")
})

而不是

try{
autio.play()
}
catch{
console.log("error playing")
}