catch request errors
This commit is contained in:
parent
778416d49b
commit
6cdbe36e6c
46
index.js
46
index.js
|
@ -53,9 +53,14 @@ module.exports.create = function(opts) {
|
||||||
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
||||||
}
|
}
|
||||||
|
|
||||||
server = require("http").createServer(
|
var mw = greenlock.middleware.sanitizeHost(greenlock.middleware(require("redirect-https")()));
|
||||||
greenlock.middleware.sanitizeHost(greenlock.middleware(require("redirect-https")()))
|
server = require("http").createServer(function(req, res) {
|
||||||
);
|
req.on("error", function(err) {
|
||||||
|
console.error("Insecure Request Network Connection Error:");
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
mw(req, res);
|
||||||
|
});
|
||||||
httpType = "http";
|
httpType = "http";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -208,24 +213,29 @@ module.exports.create = function(opts) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server = https.createServer(
|
|
||||||
greenlock.tlsOptions,
|
var mw = greenlock.middleware.sanitizeHost(function(req, res) {
|
||||||
greenlock.middleware.sanitizeHost(function(req, res) {
|
try {
|
||||||
|
greenlock.app(req, res);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
||||||
|
console.error(e);
|
||||||
try {
|
try {
|
||||||
greenlock.app(req, res);
|
res.statusCode = 500;
|
||||||
|
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
// ignore
|
||||||
console.error(e);
|
// (headers may have already been sent, etc)
|
||||||
try {
|
|
||||||
res.statusCode = 500;
|
|
||||||
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
|
||||||
} catch (e) {
|
|
||||||
// ignore
|
|
||||||
// (headers may have already been sent, etc)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
);
|
});
|
||||||
|
server = https.createServer(greenlock.tlsOptions, function(req, res) {
|
||||||
|
req.on("error", function(err) {
|
||||||
|
console.error("HTTPS Request Network Connection Error:");
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
mw(req, res);
|
||||||
|
});
|
||||||
server.type = httpType;
|
server.type = httpType;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue