1
0
Fork 0
forked from svrjs/svrjs

Fix callServerError

This commit is contained in:
Dorian Niemiec 2023-09-01 11:04:04 +02:00
parent bf3b002190
commit 03b54f94d4

116
svr.js
View file

@ -2224,9 +2224,30 @@ if (!cluster.isPrimary) {
function medCallback(p) { function medCallback(p) {
if(p) callback(p); if(p) callback(p);
else { else {
fs.access(page404, fs.constants.F_OK, function(err) { if(errorCode == 404) {
if(err) { fs.access(page404, fs.constants.F_OK, function(err) {
fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) { if(err) {
fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) {
try {
if(err) {
callback(errorCode.toString() + ".html");
} else {
callback("." + errorCode.toString());
}
} catch(err2) {
callServerError(500, undefined, generateErrorStack(err2));
}
});
} else {
try {
callback(page404);
} catch(err2) {
callServerError(500, undefined, generateErrorStack(err2));
}
}
});
} else {
fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) {
try { try {
if(err) { if(err) {
callback(errorCode.toString() + ".html"); callback(errorCode.toString() + ".html");
@ -2237,14 +2258,7 @@ if (!cluster.isPrimary) {
callServerError(500, undefined, generateErrorStack(err2)); callServerError(500, undefined, generateErrorStack(err2));
} }
}); });
} else { }
try {
callback(page404);
} catch(err2) {
callServerError(500, undefined, generateErrorStack(err2));
}
}
});
} }
} }
@ -2670,27 +2684,41 @@ if (!cluster.isPrimary) {
function medCallback(p) { function medCallback(p) {
if(p) callback(p); if(p) callback(p);
else { else {
fs.access(page404, fs.constants.F_OK, function(err) { if(errorCode == 404) {
if(err) { fs.access(page404, fs.constants.F_OK, function(err) {
fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) { if(err) {
try { fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) {
if(err) { try {
callback(errorCode.toString() + ".html"); if(err) {
} else { callback(errorCode.toString() + ".html");
callback("." + errorCode.toString()); } else {
callback("." + errorCode.toString());
}
} catch(err2) {
callServerError(500, undefined, generateErrorStack(err2));
} }
});
} else {
try {
callback(page404);
} catch(err2) { } catch(err2) {
callServerError(500, undefined, generateErrorStack(err2)); callServerError(500, undefined, generateErrorStack(err2));
} }
}); }
} else { });
} else {
fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) {
try { try {
callback(page404); if(err) {
callback(errorCode.toString() + ".html");
} else {
callback("." + errorCode.toString());
}
} catch(err2) { } catch(err2) {
callServerError(500, undefined, generateErrorStack(err2)); callServerError(500, undefined, generateErrorStack(err2));
} }
} });
}); }
} }
} }
@ -3411,27 +3439,41 @@ if (!cluster.isPrimary) {
function medCallback(p) { function medCallback(p) {
if(p) callback(p); if(p) callback(p);
else { else {
fs.access(page404, fs.constants.F_OK, function(err) { if(errorCode == 404) {
if(err) { fs.access(page404, fs.constants.F_OK, function(err) {
fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) { if(err) {
try { fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) {
if(err) { try {
callback(errorCode.toString() + ".html"); if(err) {
} else { callback(errorCode.toString() + ".html");
callback("." + errorCode.toString()); } else {
callback("." + errorCode.toString());
}
} catch(err2) {
callServerError(500, undefined, generateErrorStack(err2));
} }
});
} else {
try {
callback(page404);
} catch(err2) { } catch(err2) {
callServerError(500, undefined, generateErrorStack(err2)); callServerError(500, undefined, generateErrorStack(err2));
} }
}); }
} else { });
} else {
fs.access("." + errorCode.toString(), fs.constants.F_OK, function(err) {
try { try {
callback(page404); if(err) {
callback(errorCode.toString() + ".html");
} else {
callback("." + errorCode.toString());
}
} catch(err2) { } catch(err2) {
callServerError(500, undefined, generateErrorStack(err2)); callServerError(500, undefined, generateErrorStack(err2));
} }
} });
}); }
} }
} }