diff --git a/src/client/streamableHttp.test.ts b/src/client/streamableHttp.test.ts index 7a98cb78a..51a6a7dfa 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 c79ea0395..2adc32e10 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