Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

errorCodeMessages.ts

12 lines533 Bytes

1import { msg } from "gt-react";
2​
3import { m, type MessageResolver } from "~/i18n/messages";
4import { PREVIEW_ERROR_CODE_MESSAGES } from "./previewConstants";
5​
6/** Components pass `useMessages()` so the message follows a language switch. */
7export function describePreviewError(description: string, resolve: MessageResolver = m): string {
8 const friendly = PREVIEW_ERROR_CODE_MESSAGES[description];
9 if (friendly) return resolve(friendly);
10 if (description.length > 0) return description;
11 return resolve(msg("Network error"));