mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-14 16:27:13 +00:00
Improve error handling on the server
This commit is contained in:
parent
b8a49c2892
commit
9f2272d930
1 changed files with 10 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue