UNPKG

eventsource

Version:

WhatWG/W3C compliant EventSource client for Node.js and browsers

53 lines 1.9 kB
/** * An extended version of the `Event` emitted by the `EventSource` object when an error occurs. * While the spec does not include any additional properties, we intentionally go beyond the spec * and provide some (minimal) additional information to aid in debugging. * * @public */ export declare class ErrorEvent extends Event { /** * HTTP status code, if this was triggered by an HTTP error * Note: this is not part of the spec, but is included for better error handling. * * @public */ code?: number | undefined; /** * Optional message attached to the error. * Note: this is not part of the spec, but is included for better error handling. * * @public */ message?: string | undefined; /** * Constructs a new `ErrorEvent` instance. This is typically not called directly, * but rather emitted by the `EventSource` object when an error occurs. * * @param type - The type of the event (should be "error") * @param errorEventInitDict - Optional properties to include in the error event */ constructor(type: string, errorEventInitDict?: { message?: string | undefined; code?: number | undefined; }); } /** * For environments where DOMException may not exist, we will use a SyntaxError instead. * While this isn't strictly according to spec, it is very close. * * @param message - The message to include in the error * @returns A `DOMException` or `SyntaxError` instance * @internal */ export declare function syntaxError(message: string): SyntaxError; /** * Flatten an error into a single error message string. * Unwraps nested errors and joins them with a comma. * * @param err - The error to flatten * @returns A string representation of the error * @internal */ export declare function flattenError(err: unknown): string; //# sourceMappingURL=errors.d.ts.map