<script> window.onerror = function(message, url, line, col, error) { alert(`${message} At ${line}:${col} of ${url}`); }; function readData() { badFunc(); // Whoops, something went wrong! } readData(); </script>