diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-04-18 20:51:06 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-04-18 20:51:06 +0200 |
commit | c28df227a09cc083a266ba15defe545d8173ad15 (patch) | |
tree | 78d4893add27b4c72b3b18f2ec7ec7f5b2c41342 /modules | |
parent | a00c93ac174b4c9b01ddd020f8a6d4a32e18f5b2 (diff) |
Make error-sending code slightly more robust?
Diffstat (limited to 'modules')
-rw-r--r-- | modules/zelfoverhoor/docent.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/zelfoverhoor/docent.js b/modules/zelfoverhoor/docent.js index b44d4b6..1c738b2 100644 --- a/modules/zelfoverhoor/docent.js +++ b/modules/zelfoverhoor/docent.js @@ -1,8 +1,14 @@ window.addEventListener("error",function(err){ - var str=err.filename+":"+err.lineno+" "+err.error+": "+err.message; - var xhr=new XMLHttpRequest(); - xhr.open("POST","/zelfoverhoor/error"); - xhr.send(str); + try { + var str="("+err+") "+err.filename+":"+err.lineno+" "+err.error+": "+err.message; + var xhr=new XMLHttpRequest(); + xhr.responseType="text"; + xhr.open("POST","/zelfoverhoor/error"); + xhr.setRequestHeader("Content-Type", "text/plain"); + xhr.send(str); + } catch(e){ + console.log("Error sending error:", e); + } }); window.onbeforeunload=function(ev){ |