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"
Source
Package
Parameters
class TrpcSocketError<Shape> {
constructor(__namedParameters: TrpcSocketErrorOptionsType<Shape>) {};
topic: null | string;
shape: Shape;
payload: unknown;
}
Parameters
| Name | Type | Description |
|---|---|---|
| __namedParameters | |
Properties
topic
Topic of the failed subscription,
null
when the error is about the whole connection
Source
Type
null | string
Usage
socket.onError(({ error }) => {
if (error instanceof TrpcSocketError && error.shape.data.code === "UNAUTHORIZED") {
logout();
}
});

