fix error handling
This commit is contained in:
parent
1ab39a1abc
commit
055e24e68a
@ -86,7 +86,10 @@ Router.prototype = {
|
|||||||
|
|
||||||
// build outputter
|
// build outputter
|
||||||
var outputter = this.buildOutputter(req.headers.accept, function(err) {
|
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);
|
logger.debug('outputter: ' + outputter);
|
||||||
@ -94,10 +97,12 @@ Router.prototype = {
|
|||||||
var url = require('url').parse(req.url, true);
|
var url = require('url').parse(req.url, true);
|
||||||
// TODO sanitize url.pathname
|
// TODO sanitize url.pathname
|
||||||
this.buildEndpoint(url.pathname, function(err, endpoint) {
|
this.buildEndpoint(url.pathname, function(err, endpoint) {
|
||||||
//TODO err
|
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.error(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) {
|
endpoint.buildAction(req.method, url, function(err, action) {
|
||||||
//TODO err
|
//TODO err
|
||||||
|
Loading…
Reference in New Issue
Block a user