mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(api): ♻️ Throw ApiError instead of returning error JSON
This commit is contained in:
parent
c14621ee06
commit
fbfd237f27
88 changed files with 458 additions and 483 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { createRoute } from "@hono/zod-openapi";
|
||||
import { z } from "zod";
|
||||
import { ApiError } from "~/classes/errors/api-error";
|
||||
import { ErrorSchema } from "~/types/api";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -72,7 +73,7 @@ export default apiRoute((app) =>
|
|||
const buffer = await file.arrayBuffer();
|
||||
|
||||
if (!(await file.exists())) {
|
||||
return context.json({ error: "File not found" }, 404);
|
||||
throw new ApiError(404, "File not found");
|
||||
}
|
||||
|
||||
// Can't directly copy file into Response because this crashes Bun for now
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue