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;
 | 
					    return dummyCerts;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function handleAppScopedError(domaininfo, req, res, fn) {
 | 
					  function handleAppScopedError(tag, domaininfo, req, res, fn) {
 | 
				
			||||||
    function next(err) {
 | 
					    function next(err) {
 | 
				
			||||||
      if (!err) {
 | 
					      if (!err) {
 | 
				
			||||||
        fn(req, res);
 | 
					        fn(req, res);
 | 
				
			||||||
        return;
 | 
					        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.writeHead(500);
 | 
				
			||||||
      res.end(
 | 
					      res.end(
 | 
				
			||||||
          "<html>"
 | 
					          "<html>"
 | 
				
			||||||
@ -61,9 +71,6 @@ module.exports.create = function (securePort, certsPath, vhostsdir) {
 | 
				
			|||||||
        + "</body>"
 | 
					        + "</body>"
 | 
				
			||||||
        + "</html>"
 | 
					        + "</html>"
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					 | 
				
			||||||
      // for debugging only
 | 
					 | 
				
			||||||
      throw err;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return next;
 | 
					    return next;
 | 
				
			||||||
@ -140,15 +147,15 @@ module.exports.create = function (securePort, certsPath, vhostsdir) {
 | 
				
			|||||||
              // we always add it explicitly
 | 
					              // we always add it explicitly
 | 
				
			||||||
              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, handleAppScopedError(domaininfo, req, res, function (req, res) {
 | 
					                localApp(req, res, handleAppScopedError('localApp', domaininfo, req, res, function (req, res) {
 | 
				
			||||||
                  if (!serveFavicon) {
 | 
					                  if (!serveFavicon) {
 | 
				
			||||||
                    serveFavicon = require('serve-favicon')(path.join(__dirname, '..', 'public', 'favicon.ico'));
 | 
					                    serveFavicon = require('serve-favicon')(path.join(__dirname, '..', 'public', 'favicon.ico'));
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  // TODO redirect GET /favicon.ico to GET (req.headers.referer||'') + /favicon.ico
 | 
					                  // TODO redirect GET /favicon.ico to GET (req.headers.referer||'') + /favicon.ico
 | 
				
			||||||
                  // TODO other common root things - robots.txt, app-icon, etc
 | 
					                  // TODO other common root things - robots.txt, app-icon, etc
 | 
				
			||||||
                  serveFavicon(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(domaininfo, req, res, function (req, res) {
 | 
					                    connectContext.static(req, res, handleAppScopedError('connect.static', domaininfo, req, res, function (req, res) {
 | 
				
			||||||
                      res.writeHead(404);
 | 
					                      res.writeHead(404);
 | 
				
			||||||
                      res.end(
 | 
					                      res.end(
 | 
				
			||||||
                          "<html>"
 | 
					                          "<html>"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user