Improve error reporting

Fixes #16
master
Dessa Simpson 2020-09-19 18:14:58 -07:00
parent 76aa7b3bc4
commit b334066f8f
2 changed files with 7 additions and 7 deletions

View File

@ -110,7 +110,7 @@ function addVote(url) {
})})
.then(response => {
if (!response.ok) {
response.text().then(addRequestErr);
response.text().then(showMessage);
return;
}
updateTable();

View File

@ -72,7 +72,7 @@ app.post("/api/addRequest", async (request, response) => {
if (request.session) await validateApiToken(request.session);
if (!request.session || !request.session.user) {
response.status(401);
response.send("Must be logged in");
response.send("Session expired; please log in again");
return;
}
var banned = await db.query(Object.assign(queries.checkBan, { values: [request.session.user.id] })).then((result: pg.QueryResult) => result.rowCount > 0);
@ -99,7 +99,7 @@ app.post("/api/updateRequestState", async (request, response) => {
if (request.session) await validateApiToken(request.session);
if (!request.session || !request.session.user) {
response.status(401);
response.send("Must be logged in");
response.send("Session expired; please log in again");
return;
}
var streamerid = await db.query(queries.getStreamerId).then((result: pg.QueryResult) => result.rows[0]['userid']);
@ -132,7 +132,7 @@ app.post("/api/updateRequestScore", async (request, response) => {
if (request.session) await validateApiToken(request.session);
if (!request.session || !request.session.user) {
response.status(401);
response.send("Must be logged in");
response.send("Session expired; please log in again");
return;
}
var streamerid = await db.query(queries.getStreamerId).then((result: pg.QueryResult) => result.rows[0]['userid']);
@ -165,7 +165,7 @@ app.post("/api/deleteRequest", async (request, response) => {
if (request.session) await validateApiToken(request.session);
if (!request.session || !request.session.user) {
response.status(401);
response.send("Must be logged in");
response.send("Session expired; please log in again");
return;
}
var streamerid = await db.query(queries.getStreamerId).then((result: pg.QueryResult) => result.rows[0]['userid']);
@ -193,7 +193,7 @@ app.post("/api/addVote", async (request,response) => {
if (request.session) await validateApiToken(request.session);
if (!request.session || !request.session.user) {
response.status(401);
response.send("Must be logged in");
response.send("Session expired; please log in again");
return;
}
var banned = await db.query(Object.assign(queries.checkBan,{ values: [request.session.user.id] })).then((result: pg.QueryResult) => result.rowCount > 0);
@ -221,7 +221,7 @@ app.post("/api/deleteVote", async (request,response) => {
if (request.session) await validateApiToken(request.session);
if (!request.session || !request.session.user) {
response.status(401);
response.send("Must be logged in");
response.send("Session expired; please log in again");
return;
}
if (!request.body.url) {