From 6b90e1ada8945964e47bd23f1f3e57f932e398e7 Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Fri, 28 Nov 2025 22:09:07 +0900 Subject: [PATCH] fix(client): use StreamableHTTPError instead of plain Error in send() (#1178) Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com> --- src/client/streamableHttp.test.ts | 2 +- src/client/streamableHttp.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/streamableHttp.test.ts b/src/client/streamableHttp.test.ts index 7a98cb78..51a6a7df 100644 --- a/src/client/streamableHttp.test.ts +++ b/src/client/streamableHttp.test.ts @@ -209,7 +209,7 @@ describe('StreamableHTTPClientTransport', () => { const errorSpy = vi.fn(); transport.onerror = errorSpy; - await expect(transport.send(message)).rejects.toThrow('Error POSTing to endpoint (HTTP 404)'); + await expect(transport.send(message)).rejects.toThrow('Streamable HTTP error: Error POSTing to endpoint: Session not found'); expect(errorSpy).toHaveBeenCalled(); }); diff --git a/src/client/streamableHttp.ts b/src/client/streamableHttp.ts index c79ea039..2adc32e1 100644 --- a/src/client/streamableHttp.ts +++ b/src/client/streamableHttp.ts @@ -534,7 +534,7 @@ export class StreamableHTTPClientTransport implements Transport { } } - throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`); + throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`); } // Reset auth loop flag on successful response