import { formatError, PdsWriteError } from "../errors.ts"; // Wraps a PDS write so any failure surfaces as a PdsWriteError. export async function withPdsError( label: string, fn: () => Promise, ): Promise { try { return await fn(); } catch (err) { if (err instanceof PdsWriteError) throw err; throw new PdsWriteError(`${label}: ${formatError(err)}`); } }