mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
parseError and much improved ServerQueryInput
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import type { ApiError } from "@issue/shared";
|
||||||
|
|
||||||
export * as issue from "@/lib/server/issue";
|
export * as issue from "@/lib/server/issue";
|
||||||
export * as organisation from "@/lib/server/organisation";
|
export * as organisation from "@/lib/server/organisation";
|
||||||
export * as project from "@/lib/server/project";
|
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 timer from "@/lib/server/timer";
|
||||||
export * as user from "@/lib/server/user";
|
export * as user from "@/lib/server/user";
|
||||||
|
|
||||||
export type ServerQueryInput = {
|
export type ServerQueryInput<T = unknown> = {
|
||||||
onSuccess?: (data: any, res: Response) => void;
|
onSuccess?: (data: T, res: Response) => void;
|
||||||
onError?: (error: string) => 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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user