diff --git a/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx b/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx index f4d0357ace..d6242a3be2 100644 --- a/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx +++ b/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx @@ -156,7 +156,8 @@ describe("useTimelineDeleteOps: ripple undo label", () => { expect(body.targets).toHaveLength(elements.length); }); - it("a refused delete names its count: 1 clip, 2 clips", async () => { + // fails without the fix: the refused delete dropped the server's status, so telemetry could not say why it failed. + it("a refused delete names its count and the server's status: 1 clip, 2 clips", async () => { vi.stubGlobal( "fetch", vi.fn(async (input: RequestInfo | URL) => @@ -179,8 +180,8 @@ describe("useTimelineDeleteOps: ripple undo label", () => { }); expect(showToast.mock.calls.map(([message]) => message)).toEqual([ - "Failed to delete 1 clip from index.html", - "Failed to delete 2 clips from index.html", + "Failed to delete 1 clip from index.html (500): {}", + "Failed to delete 2 clips from index.html (500): {}", ]); }); diff --git a/packages/studio/src/hooks/useTimelineDeleteOps.ts b/packages/studio/src/hooks/useTimelineDeleteOps.ts index 67273a2a82..f4c0ec41bb 100644 --- a/packages/studio/src/hooks/useTimelineDeleteOps.ts +++ b/packages/studio/src/hooks/useTimelineDeleteOps.ts @@ -26,7 +26,7 @@ import type { } from "./useTimelineGroupEditing"; import { studioApiFetch } from "../utils/studioApiFetch"; import { countOf } from "../utils/countOf"; -import { heldFileWordsOf } from "../utils/studioSaveDiagnostics"; +import { createStudioSaveHttpError } from "../utils/studioSaveDiagnostics"; /** Apply already-resolved ripple changes to the surviving elements for the * optimistic store update after a delete. Pure — no IO. */ @@ -141,9 +141,10 @@ export function useTimelineDeleteOps({ }, ); if (!removeResponse.ok) { - throw new Error( - (await heldFileWordsOf(removeResponse, targetPath)) ?? - `Failed to delete ${countOf(sameFile.length, "clip")} from ${targetPath}`, + throw await createStudioSaveHttpError( + removeResponse, + `Failed to delete ${countOf(sameFile.length, "clip")} from ${targetPath}`, + { path: targetPath }, ); } const removeData = (await removeResponse.json()) as { content?: string };