breaking change: doErrorPage moved to wtvshared.doErrorPage

- but I fixed flashrom error handling..
- added a passthrough for old scripts
This commit is contained in:
zefie
2021-08-16 08:01:45 -04:00
parent 1967c076a9
commit fdd2f16f3b
22 changed files with 96 additions and 113 deletions

View File

@@ -230,6 +230,37 @@ class WTVShared {
});
}
doErrorPage(code, data = null, pc_mode = false) {
var headers = null;
switch (code) {
case 404:
if (data === null) data = "The service could not find the requested page.";
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 = "HackTV ran into a technical problem.";
if (pc_mode) headers = "500 Internal Server Error\n";
else headers = code + " " + data + "\n";
headers += "Content-Type: text/html\n";
break;
case 401:
if (data === null) data = "Access Denied.";
if (pc_mode) headers = "401 Access Denied\n";
else headers = code + " " + data + "\n";
headers += "Content-Type: text/html\n";
break;
default:
headers = code + " " + data + "\n";
headers += "Content-Type: text/html\n";
break;
}
console.error(" * doErrorPage Called:", code, data);
return new Array(headers, data);
}
/**
* Strips bad things from paths
* @param {string} base Base path