add error handling to the one route we need it in
This commit is contained in:
parent
fd6b3a73fc
commit
0bdab37f2e
|
@ -16,14 +16,23 @@ export function Command() {
|
|||
) : (
|
||||
""
|
||||
)}
|
||||
<h1 className="mb-2 border-b pb-2 text-center text-4xl tracking-tighter">
|
||||
{data.name}
|
||||
</h1>
|
||||
<div className="space-y-1 p-4">
|
||||
<p className="font-semibold">{data.desc}</p>
|
||||
<p>Only for privlidged: {data.restricted.toString()}</p>
|
||||
<p>Needs mod: {data.mod.toString()}</p>
|
||||
</div>
|
||||
|
||||
{data.error ? (
|
||||
<div className="rounded-lg bg-red-600 p-6 text-white shadow-lg">
|
||||
<h1>Error: {data.error}</h1>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<h1 className="mb-2 border-b pb-2 text-center text-4xl tracking-tighter">
|
||||
{data.name}
|
||||
</h1>
|
||||
<div className="space-y-1 p-4">
|
||||
<p className="font-semibold">{data.desc}</p>
|
||||
<p>Only for privlidged: {data.restricted.toString()}</p>
|
||||
<p>Needs mod: {data.mod.toString()}</p>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ fastify.get("/api/v1/commands", (req, res) => {
|
|||
});
|
||||
|
||||
fastify.get("/api/v1/commands/:name", (req, res) => {
|
||||
if (!(req.params.name in client.commands)) {
|
||||
return { error: "Command not found" };
|
||||
}
|
||||
|
||||
return client.commands[req.params.name];
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue