feat(web): shared status-aware error-message helper + MutationError component (#63)

This commit is contained in:
2026-06-08 17:17:14 +02:00
parent 17bfd3e9d8
commit cad5a980c5
8 changed files with 111 additions and 29 deletions
+3 -8
View File
@@ -6,20 +6,15 @@ import {
import i18n from "../i18n";
import { toastManager } from "../toast/toast-manager";
import { HttpError, InUseError } from "./queries";
import { errorMessageKey } from "./error-message";
function mutationErrorMessage(
error: unknown,
meta: MutationMeta | undefined,
): string {
if (meta?.errorMessage) return i18n.t(meta.errorMessage);
if (error instanceof InUseError) {
return i18n.t("actions.inUse", { count: error.count });
}
if (error instanceof HttpError && error.status === 503) {
return i18n.t("search.unavailable");
}
return i18n.t("toast.error");
const { key, opts } = errorMessageKey(error);
return i18n.t(key, opts);
}
/** Builds the app's QueryClient, including the MutationCache that bridges every