Display error messages

This commit is contained in:
tdurieux
2021-03-19 13:26:29 +01:00
parent 54bc4e176d
commit 72715dfcd9
17 changed files with 117 additions and 33 deletions
+2 -1
View File
@@ -23,6 +23,7 @@ async function anonymizeRepository(options) {
console.log("The repository is expired");
await repoUtils.updateStatus(repoConfig, "expired");
await repoUtils.removeRepository(repoConfig);
throw "repository_expired";
return;
}
}
@@ -150,7 +151,7 @@ router.get("/:repoId/file/:path*", async (req, res) => {
);
return res.sendFile(ppath, { dotfiles: "allow" });
} else {
return res.status(404).send({ error: "file_not_found" });
return res.status(404).json({ error: "file_not_found" });
}
} catch (error) {
console.error(error);
+2 -2
View File
@@ -277,7 +277,7 @@ router.post("/", async (req, res) => {
if (repoConfig.options.mode == "download") {
// details.size is in kilobytes
if (details.size > config.MAX_REPO_SIZE) {
return res.status(500).send({ error: "invalid_mode" });
return res.status(500).send({ error: "non_supported_mode" });
}
}
@@ -326,7 +326,7 @@ router.post("/", async (req, res) => {
await repoUtils.updateStatus(repoConfig, "error");
return res
.status(500)
.json({ error: "unable_to_access", message: error.message });
.json({ error: "unable_to_anonymize", message: error.message });
}
res.send("ok");
});
+1 -1
View File
@@ -60,7 +60,7 @@ router.get("/all_repositories", async (req, res) => {
{ projection: { repositories: 1 } }
);
if (!user) {
res.status(401).send("User not found");
res.status(401).send({error: "user_not_found"});
}
if (user.repositories && req.query.force !== "1") {
return res.json(user.repositories);
+1 -1
View File
@@ -62,7 +62,7 @@ async function webView(req, res) {
console.error(error);
return res.status(500).send({ error });
}
return res.status(404).send("File_not_found");
return res.status(404).send("file_not_found");
}
router.get("/:repoId/*", webView);