Skip to main content

Throw Error

Simple throwing error for situation logic.

import { HttpError, nhttp } from "https://deno.land/x/nhttp@1.3.26/mod.ts";

const app = nhttp();

app.post("/user", async ({ response }) => {
const data = await saveUser();
if (!data) {
throw new HttpError(400, "Bad request for save");
}
response.send(data);
});

app.listen(3000);