UNPKG

@nktkas/hyperliquid

Version:

Hyperliquid API SDK for all major JS runtimes, written in TypeScript.

34 lines (33 loc) 1.03 kB
/** * Base contracts shared by every transport: the request and subscription * interfaces and the root of the transport error hierarchy. * @module */ import { HyperliquidError } from "../_base.js"; /** * Thrown when an error occurs at the transport level (e.g., timeout). * * @example * ```ts * import { HttpTransport, TransportError } from "@nktkas/hyperliquid"; * * const transport = new HttpTransport(); * try { * // Throws a TransportError subclass on a timeout, an abort, or an HTTP failure. * await transport.request("info", { type: "allMids" }); * } catch (error) { * if (error instanceof TransportError) { * console.error(`Transport failure: ${error.message}`); * } * } * ``` */ export class TransportError extends HyperliquidError { /** * Creates a transport-level error. * * The platform-specific failure goes into `options.cause`. */ constructor(message, options){ super(message, options); this.name = "TransportError"; } } //# sourceMappingURL=_base.js.map