Improve error handling on the server

This commit is contained in:
Ophir LOJKINE 2018-11-27 09:57:58 +01:00
parent b8a49c2892
commit 9f2272d930

View file

@ -42,6 +42,16 @@ function logRequest (request) {
}
function handler (request, response) {
try {
handleRequest(request, response);
} catch(err) {
console.trace(err);
response.writeHead(500, {'Content-Type': 'text/plain'});
response.end(err.toString());
}
}
function handleRequest (request, response) {
var parts = request.url.split('/');
if (parts[0] === '') parts.shift();