From 2193edfa40ef4e53342126ec1badc10338ae35b6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 25 Nov 2017 16:33:41 +0100 Subject: zelfoverhoor: Add js error reporting --- modules/zelfoverhoor/docent.js | 7 +++++++ modules/zelfoverhoor/qs.js | 7 +++++++ modules/zelfoverhoor/zelfoverhoor.js | 8 ++++++++ 3 files changed, 22 insertions(+) (limited to 'modules/zelfoverhoor') diff --git a/modules/zelfoverhoor/docent.js b/modules/zelfoverhoor/docent.js index 456ea2f..2aef2e8 100644 --- a/modules/zelfoverhoor/docent.js +++ b/modules/zelfoverhoor/docent.js @@ -1,3 +1,10 @@ +window.addEventListener("error",function(err){ + console.log(JSON.stringify(err)); + var xhr=new XMLHttpRequest(); + xhr.open("POST","/zelfoverhoor/error"); + xhr.send(JSON.stringify(err)); +}); + var questionsets=null; var currentlyEditing=null; diff --git a/modules/zelfoverhoor/qs.js b/modules/zelfoverhoor/qs.js index 43d68f0..c07f8be 100644 --- a/modules/zelfoverhoor/qs.js +++ b/modules/zelfoverhoor/qs.js @@ -1,3 +1,10 @@ +window.addEventListener("error",function(err){ + console.log(JSON.stringify(err)); + var xhr=new XMLHttpRequest(); + xhr.open("POST","/zelfoverhoor/error"); + xhr.send(JSON.stringify(err)); +}); + var setname=questionset.name; var setdescription=questionset.description; var questions=questionset.questions; diff --git a/modules/zelfoverhoor/zelfoverhoor.js b/modules/zelfoverhoor/zelfoverhoor.js index 8f87f75..d1d3068 100644 --- a/modules/zelfoverhoor/zelfoverhoor.js +++ b/modules/zelfoverhoor/zelfoverhoor.js @@ -220,6 +220,14 @@ module.exports=function(app,io,_moddir){ res.send(); }); + app.post("/zelfoverhoor/error",function(req,res){ + if(typeof req.body=="string"){ + fs.appendFile(moddir+"/errors.txt",req.body,function(err){ + if(err)console.log(err); + }); + } + }); + app.get("/zelfoverhoor/docent/docent.js",function(req,res){ res.sendFile(moddir+"/docent.js"); }); -- cgit v1.2.3-70-g09d2