Make error reporting directory configurable

master
Sven Slootweg 7 years ago
parent af10fd8d63
commit 0c7bd699eb

@ -5,5 +5,8 @@
"listLimit": 100, "listLimit": 100,
"pasteInterval": 1 "pasteInterval": 1
} }
},
"errors": {
"directory": "./errors"
} }
} }

@ -2,13 +2,14 @@
'use strict'; 'use strict';
const errorReporter = require("./src/error-reporting"); const config = require("./config.json");
const path = require("path"); const path = require("path");
const errorReporter = require("./src/error-reporting")(path.join(__dirname, config.errors.directory));
const express = require("express"); const express = require("express");
const expressWs = require("express-ws"); const expressWs = require("express-ws");
const config = require("./config.json");
const clientStore = require("./src/client-store")(); const clientStore = require("./src/client-store")();
const scraper = require("./src/scraper")({ const scraper = require("./src/scraper")({

@ -4,17 +4,17 @@ const path = require("path");
const reportErrors = require("report-errors"); const reportErrors = require("report-errors");
const mkdirp = require("mkdirp"); const mkdirp = require("mkdirp");
let errorPath = path.join(__dirname, "../errors"); module.exports = function(errorPath) {
mkdirp.sync(errorPath);
mkdirp.sync(errorPath); module.exports = reportErrors(errorPath, {
doNotCrash: true,
handler: (error, context) => {
console.error("Unhandled error", error.stack);
module.exports = reportErrors(errorPath, { if (error.rateLimited !== true) {
doNotCrash: true, process.exit(1);
handler: (error, context) => { }
console.error("Unhandled error", error.stack);
if (error.rateLimited !== true) {
process.exit(1);
} }
} });
}); };

Loading…
Cancel
Save