From c28df227a09cc083a266ba15defe545d8173ad15 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 18 Apr 2018 20:51:06 +0200 Subject: Make error-sending code slightly more robust? --- modules/zelfoverhoor/docent.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'modules/zelfoverhoor') 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){ -- cgit v1.2.3-70-g09d2