5257dfbaab
Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
16 lines
397 B
TypeScript
16 lines
397 B
TypeScript
import { t } from "@/lib/i18n";
|
|
export type LoadState<T> =
|
|
| { status: "loading" }
|
|
| { status: "ready"; data: T }
|
|
| { status: "error"; message: string };
|
|
|
|
export function toRouteErrorState(
|
|
error: unknown,
|
|
fallbackMessage = t("common:failedToLoadRoute"),
|
|
): LoadState<never> {
|
|
return {
|
|
status: "error",
|
|
message: error instanceof Error ? error.message : fallbackMessage,
|
|
};
|
|
}
|