export const extractErrorMessage = (err: unknown): string => {
  const axiosError = err as { response?: { data?: { detail?: string | Array<{ msg?: string }> } } };
  const detail = axiosError?.response?.data?.detail;
  if (typeof detail === "string") return detail;
  if (Array.isArray(detail)) {
    return detail.map((d) => typeof d === "string" ? d : d.msg || JSON.stringify(d)).join(", ");
  }
  return "Failed to save";
};
