core.normalizeerrorevent
Home > @medplum/core > normalizeErrorEvent
normalizeErrorEvent() function
Normalizes the various error event shapes dispatched by different WebSocket implementations into a single ErrorEvent carrying a real Error, so downstream listeners always get message and error regardless of the underlying implementation:
- Browsers dispatch a plain
Eventwith no error details (per the WHATWG WebSocket spec). - Node'swslibrary and Node's built-in (undici)WebSocketdispatch anErrorEventwith bothmessageanderror. - Bun dispatches a plainEventwith amessagestring but noerror.
Signature:
export declare function normalizeErrorEvent(event: Event | ErrorEvent, target: unknown): ErrorEvent;
Parameters
Parameter | Type | Description |
|---|---|---|
event | Event | ErrorEvent | The |
target | unknown | The |
Returns:
An ErrorEvent with a populated message and error.