parseError and much improved ServerQueryInput

This commit is contained in:
Oliver Bryan
2026-01-13 15:33:38 +00:00
parent 1ab5c80691
commit 4e93eb5878

View File

@@ -1,3 +1,5 @@
import type { ApiError } from "@issue/shared";
export * as issue from "@/lib/server/issue";
export * as organisation from "@/lib/server/organisation";
export * as project from "@/lib/server/project";
@@ -5,7 +7,16 @@ export * as sprint from "@/lib/server/sprint";
export * as timer from "@/lib/server/timer";
export * as user from "@/lib/server/user";
export type ServerQueryInput = {
onSuccess?: (data: any, res: Response) => void;
onError?: (error: string) => void;
export type ServerQueryInput<T = unknown> = {
onSuccess?: (data: T, res: Response) => void;
onError?: (error: ApiError | string) => void;
};
export function parseError(error: ApiError | string): string {
if (typeof error === "string") return error;
if (error.details) {
const messages = Object.values(error.details).flat();
return messages.join(", ");
}
return error.error;
}