Better error handling
This commit is contained in:
parent
2691860bcb
commit
91e03e5866
1 changed files with 3 additions and 2 deletions
5
index.js
5
index.js
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue