File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1+ import { EventSource , type ErrorEvent , type EventSourceInit } from "eventsource" ;
12import { Transport } from "../shared/transport.js" ;
23import { JSONRPCMessage , JSONRPCMessageSchema } from "../types.js" ;
3- import { EventSource , type EventSourceInit } from "eventsource" ;
4+
5+ export class SseError extends Error {
6+ constructor (
7+ public readonly code : number | undefined ,
8+ message : string | undefined ,
9+ public readonly event : ErrorEvent ,
10+ ) {
11+ super ( `SSE error: ${ message } ` ) ;
12+ }
13+ }
414
515/**
616 * Client transport for SSE: this will connect to a server using Server-Sent Events for receiving
@@ -42,7 +52,7 @@ export class SSEClientTransport implements Transport {
4252 this . _abortController = new AbortController ( ) ;
4353
4454 this . _eventSource . onerror = ( event ) => {
45- const error = new Error ( `SSE error: ${ JSON . stringify ( event ) } ` ) ;
55+ const error = new SseError ( event . code , event . message , event ) ;
4656 reject ( error ) ;
4757 this . onerror ?.( error ) ;
4858 } ;
You can’t perform that action at this time.
0 commit comments