Получение и репорт ошибок JavaScript с помощью window.onerror.



https://www.sitepoint.com/capture-and-report-javascript-errors-with-window-onerror/