allow error messages to be customized via config
This commit is contained in:
@@ -675,34 +675,36 @@ class WTVShared {
|
||||
|
||||
doErrorPage(code, data = null, details = null, pc_mode = false) {
|
||||
var headers = null;
|
||||
var minisrv_config = this.minisrv_config;
|
||||
switch (code) {
|
||||
case 401:
|
||||
if (data === null) data = "Authorization Required.";
|
||||
if (data === null) data = minisrv_config.config.errorMessages[code].replace(/\$\{(.+)\}/g, function (x) { return minisrv_config.config[x.replace("${", '').replace('}', '')] });
|
||||
if (pc_mode) headers = "401 Unauthorized\n";
|
||||
else headers = code + " " + data + "\n";
|
||||
headers += "Content-Type: text/html\n";
|
||||
break;
|
||||
case 403:
|
||||
if (data === null) data = "The publisher of that page has not authorized you to view it.";
|
||||
if (data === null) data = minisrv_config.config.errorMessages[code].replace(/\$\{(.+)\}/g, function (x) { return minisrv_config.config[x.replace("${", '').replace('}', '')] });
|
||||
if (pc_mode) headers = "403 Forbidden\n";
|
||||
else headers = code + " " + data + "\n";
|
||||
headers += "Content-Type: text/html\n";
|
||||
break;
|
||||
case 404:
|
||||
if (data === null) data = "The service could not find the requested page.";
|
||||
if (data === null) data = minisrv_config.config.errorMessages[code].replace(/\$\{(.+)\}/g, function (x) { return minisrv_config.config[x.replace("${", '').replace('}', '')] });
|
||||
if (pc_mode) headers = "404 Not Found\n";
|
||||
else headers = code + " " + data + "\n";
|
||||
headers += "Content-Type: text/html\n";
|
||||
break;
|
||||
case 400:
|
||||
case 500:
|
||||
if (data === null) data = this.minisrv_config.config.service_name + " ran into a technical problem.";
|
||||
if (data === null) data = minisrv_config.config.errorMessages[code].replace(/\$\{(.+)\}/g, function (x) { console.log(x); return minisrv_config.config[x.replace("${", '').replace('}', '')] });
|
||||
if (details) data += "<br>Details:<br>" + details;
|
||||
if (pc_mode) headers = "500 Internal Server Error\n";
|
||||
else headers = code + " " + data + "\n";
|
||||
headers += "Content-Type: text/html\n";
|
||||
break;
|
||||
default:
|
||||
if (data === null && this.minisrv_config.config.errorMessages[code]) data = minisrv_config.config.errorMessages[code].replace(/\$\{(.+)\}/g, function (x) { return minisrv_config.config[x.replace("${",'').replace('}','')] });
|
||||
headers = code + " " + data + "\n";
|
||||
headers += "Content-Type: text/html\n";
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user