js error handler

This commit is contained in:
troy
2022-01-08 01:01:09 +01:00
parent 0b888cd234
commit 28e68b094c
3 changed files with 18 additions and 0 deletions

7
js-error-logger.js Normal file
View File

@@ -0,0 +1,7 @@
window.onerror = function(message, source, lineno, colno, error) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "https://troy-grunt.de/api.php", true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
var params = JSON.stringify({'type':'error_collector','message':message,'source':source,'line':lineno,'col':colno,'err': error});
xmlhttp.send(params);
};