improve error message

This commit is contained in:
tdurieux
2021-04-27 08:01:02 +02:00
parent b6c4b780b8
commit dc84de9d84
4 changed files with 66 additions and 30 deletions
+8 -8
View File
@@ -60,10 +60,10 @@ router.get("/:repoId/", async (req, res) => {
if (repository) {
return res.json(repository);
}
res.status(404).send("repo_not_found");
res.status(404).send({error: "repo_not_found"});
} catch (error) {
console.error(req.path, error);
res.status(500).send(error);
res.status(500).json({ error });
}
});
@@ -219,10 +219,10 @@ router.get("/:owner/:repo/", async (req, res) => {
if (repository) {
return res.json(repository);
}
res.status(404).send("repo_not_found");
res.status(404).send({error: "repo_not_found"});
} catch (error) {
console.error(req.path, error);
res.status(500).send(error);
res.status(500).json({ error });
}
});
@@ -237,10 +237,10 @@ router.get("/:owner/:repo/branches", async (req, res) => {
if (repository) {
return res.json(repository);
}
res.status(404).send("repo_not_found");
res.status(404).send({error: "repo_not_found"});
} catch (error) {
console.error(req.path, error);
res.status(500).send(error);
res.status(500).json({ error });
}
});
@@ -255,9 +255,9 @@ router.get("/:owner/:repo/readme", async (req, res) => {
if (readme) {
return res.send(readme);
}
res.status(404).send("repo_not_found");
res.status(404).send({error: "repo_not_found"});
} catch (error) {
res.status(500).send(error);
res.status(500).json({ error });
}
});