Better error handling

This commit is contained in:
Dorian Niemiec 2023-08-12 12:18:20 +02:00
parent 2691860bcb
commit 91e03e5866

View file

@ -149,14 +149,15 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
socket.write(envEncoded.length + ":" + envEncoded + ",");
req.pipe(socket, {end: false});
}).on("error", function (error) {
var errorcode = (error.code == "ENOTFOUND" || error.code == "EHOSTUNREACH" || error.code == "ECONNREFUSED") ? 503 : 500;
if (!callServerError) {
res.writeHead(500, {
res.writeHead(errorcode, {
"Content-Type": "text/html",
"Server": "OrangeCircle/" + version
});
res.end("<html><head></head><body><h1>OrangeCircle Error!</h1><p>Reason: " + error.message + "</p></body></html>");
} else {
callServerError(500, "OrangeCircle/" + version, error);
callServerError(errorcode, "OrangeCircle/" + version, error);
}
});