Skip to content

Commit

Permalink
Update error handling to display client forbidden error
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Vu committed Jul 14, 2020
1 parent 4f6758a commit 0cd398d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ app.get("/api/rules", async (req, res) => {
const response = await get(requestConfig);

if (response.statusCode !== 200) {
throw new Error(response.body.error.message);
if (response.statusCode === 403) {
res.status(403).send(response.body);
} else {
throw new Error(response.body.error.message);
}
}

res.send(response);
Expand Down Expand Up @@ -139,7 +143,6 @@ const streamTweets = (socket, token) => {
reconnect(stream, socket, token);
});
} catch (e) {
console.log("e =>", e);
socket.emit("authError", authMessage);
}
};
Expand All @@ -157,7 +160,6 @@ io.on("connection", async (socket) => {
io.emit("connect", "Client connected");
const stream = streamTweets(io, token);
} catch (e) {
console.log("here", e);
io.emit("authError", authMessage);
}
});
Expand Down

0 comments on commit 0cd398d

Please sign in to comment.