fix error handling

This commit is contained in:
Meutel 2014-05-22 19:00:22 +02:00
parent 1ab39a1abc
commit 055e24e68a

View File

@ -86,7 +86,10 @@ Router.prototype = {
// build outputter
var outputter = this.buildOutputter(req.headers.accept, function(err) {
//TODO error code, terminate resp
logger.error(err);
resp.writeHead(500, 'outputter failure');
resp.write(err.message);
resp.end();
});
logger.debug('outputter: ' + outputter);
@ -94,10 +97,12 @@ Router.prototype = {
var url = require('url').parse(req.url, true);
// TODO sanitize url.pathname
this.buildEndpoint(url.pathname, function(err, endpoint) {
//TODO err
if (err) {
logger.error(err);
// TODO write error in response
resp.writeHead(404, 'no endpoint for ' + url.pathname);
resp.write(err.message);
resp.end();
return;
}
endpoint.buildAction(req.method, url, function(err, action) {
//TODO err