better error handling
This commit is contained in:
parent
fcc8e232dc
commit
3e026237bd
|
@ -99,6 +99,33 @@ module.exports.create = function (securePort, certsPath, vhostsdir) {
|
||||||
function localAppWrapped(req, res) {
|
function localAppWrapped(req, res) {
|
||||||
console.log('[debug]', domaininfo.hostname + '/' + domaininfo.pathname, req.url);
|
console.log('[debug]', domaininfo.hostname + '/' + domaininfo.pathname, req.url);
|
||||||
localApp(req, res, function (err) {
|
localApp(req, res, function (err) {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
res.end(
|
||||||
|
"<html>"
|
||||||
|
+ "<head>"
|
||||||
|
+ '<link rel="icon" href="favicon.ico" />'
|
||||||
|
+ "</head>"
|
||||||
|
+ "<body>"
|
||||||
|
+ "<pre>"
|
||||||
|
+ "<code>"
|
||||||
|
+ "Method: " + req.method
|
||||||
|
+ '\n'
|
||||||
|
+ "Hostname: " + domaininfo.hostname
|
||||||
|
+ '\n'
|
||||||
|
+ "App: " + (domaininfo.pathname ? (domaininfo.pathname + '/') : '')
|
||||||
|
+ '\n'
|
||||||
|
+ "Route: " + req.url//.replace(/^\//, '')
|
||||||
|
+ '\n'
|
||||||
|
// TODO better sanatization
|
||||||
|
+ 'Error: ' + (err.message || err.toString()).replace(/</g, '<')
|
||||||
|
+ "</code>"
|
||||||
|
+ "</pre>"
|
||||||
|
+ "</body>"
|
||||||
|
+ "</html>"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!serveFavicon) {
|
if (!serveFavicon) {
|
||||||
serveFavicon = require('serve-favicon')(path.join(__dirname, '..', 'public', 'favicon.ico'));
|
serveFavicon = require('serve-favicon')(path.join(__dirname, '..', 'public', 'favicon.ico'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue