import { handleServerApiError } from "./server-api-guard";

export async function withServerAction<T>(fn: () => Promise<T>): Promise<T> {
  try {
    return await fn();
  } catch (error: any) {
    await handleServerApiError(error);
    throw error; // Fallback, handleServerApiError should never return
  }
}