Skip to main content
Version: v10.0.0

TrpcSocketError

Error of a tRPC subscription, reported to the socket.onError callbacks and to the onEnd of its listeners. The server ended the subscription (or rejected the connection when topic is null , which ends no subscription),

shape holds the error it sent.


Import
import { TrpcSocketError } from "@hyper-fetch/trpc"

Parameters​

class TrpcSocketError<Shape> {
constructor(__namedParameters: TrpcSocketErrorOptionsType<Shape>) {};
topic: null | string;
shape: Shape;
payload: unknown;
}
Parameters
NameTypeDescription
__namedParameters
TrpcSocketErrorOptionsType<Shape>

Properties​

payload​

Input of the failed subscription

Type
unknown

shape​

Error sent by the server, after the transformer

Type
Shape

topic​

Topic of the failed subscription, null when the error is about the whole connection

Type
null | string

Usage​

socket.onError(({ error }) => {
if (error instanceof TrpcSocketError && error.shape.data.code === "UNAUTHORIZED") {
logout();
}
});