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
|
|
@ -6,6 +6,7 @@ import { type SQL, and, eq, isNull } from "@versia/kit/drizzle";
|
|||
import { OpenIdAccounts, RolePermissions, Users } from "@versia/kit/tables";
|
||||
import { setCookie } from "hono/cookie";
|
||||
import { SignJWT } from "jose";
|
||||
import { ApiError } from "~/classes/errors/api-error.ts";
|
||||
import type { PluginType } from "../../index.ts";
|
||||
import { automaticOidcFlow } from "../../utils.ts";
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ export default (plugin: PluginType): void => {
|
|||
.providers.find((provider) => provider.id === issuerParam);
|
||||
|
||||
if (!issuer) {
|
||||
return context.json({ error: "Issuer not found" }, 404);
|
||||
throw new ApiError(404, "Issuer not found");
|
||||
}
|
||||
|
||||
const userInfo = await automaticOidcFlow(
|
||||
|
|
@ -303,10 +304,7 @@ export default (plugin: PluginType): void => {
|
|||
}
|
||||
|
||||
if (!flow.application) {
|
||||
return context.json(
|
||||
{ error: "Application not found" },
|
||||
500,
|
||||
);
|
||||
throw new ApiError(500, "Application not found");
|
||||
}
|
||||
|
||||
const code = randomString(32, "hex");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue