基于 window.onerror 实现错误上报遇到的问题

throw new Error(“This is a test error in Cocos Creator 3.x”)不能被window.onerror 监听到。要怎么实现错误收集呢。