slightly better debugging
This commit is contained in:
parent
26bcf0d0a0
commit
e1e4d86941
|
@ -29,14 +29,24 @@ module.exports.create = function (securePort, certsPath, vhostsdir) {
|
|||
return dummyCerts;
|
||||
}
|
||||
|
||||
function handleAppScopedError(domaininfo, req, res, fn) {
|
||||
function handleAppScopedError(tag, domaininfo, req, res, fn) {
|
||||
function next(err) {
|
||||
if (!err) {
|
||||
fn(req, res);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(err);
|
||||
if (res.headersSent) {
|
||||
console.error('[ERROR] handleAppScopedError headersSent');
|
||||
console.log(err);
|
||||
console.log(err.stack);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('[ERROR] handleAppScopedError');
|
||||
console.log(err);
|
||||
console.log(err.stack);
|
||||
|
||||
res.writeHead(500);
|
||||
res.end(
|
||||
"<html>"
|
||||
|
@ -61,9 +71,6 @@ module.exports.create = function (securePort, certsPath, vhostsdir) {
|
|||
+ "</body>"
|
||||
+ "</html>"
|
||||
);
|
||||
|
||||
// for debugging only
|
||||
throw err;
|
||||
}
|
||||
|
||||
return next;
|
||||
|
@ -140,15 +147,15 @@ module.exports.create = function (securePort, certsPath, vhostsdir) {
|
|||
// we always add it explicitly
|
||||
function localAppWrapped(req, res) {
|
||||
console.log('[debug]', domaininfo.hostname + '/' + domaininfo.pathname, req.url);
|
||||
localApp(req, res, handleAppScopedError(domaininfo, req, res, function (req, res) {
|
||||
localApp(req, res, handleAppScopedError('localApp', domaininfo, req, res, function (req, res) {
|
||||
if (!serveFavicon) {
|
||||
serveFavicon = require('serve-favicon')(path.join(__dirname, '..', 'public', 'favicon.ico'));
|
||||
}
|
||||
|
||||
// TODO redirect GET /favicon.ico to GET (req.headers.referer||'') + /favicon.ico
|
||||
// TODO other common root things - robots.txt, app-icon, etc
|
||||
serveFavicon(req, res, handleAppScopedError(domaininfo, req, res, function (req, res) {
|
||||
connectContext.static(req, res, handleAppScopedError(domaininfo, req, res, function (req, res) {
|
||||
serveFavicon(req, res, handleAppScopedError('serveFavicon', domaininfo, req, res, function (req, res) {
|
||||
connectContext.static(req, res, handleAppScopedError('connect.static', domaininfo, req, res, function (req, res) {
|
||||
res.writeHead(404);
|
||||
res.end(
|
||||
"<html>"
|
||||
|
|
Loading…
Reference in New Issue