OrpcSocketError
Error of an oRPC subscription, reported to the
socket.onError
callbacks.
topic
and
payload
tell which
subscription failed.
shape
is the error the server sent, in the shape of
ORPCError.toJSON()
- it is
nullwhen the failure did not come from a procedure, e.g. a dropped stream or a malformed message. The original error is the
cause
.
Import
import { OrpcSocketError } from "@hyper-fetch/orpc"
Source
Package
Parameters
class OrpcSocketError<Code, Data> {
constructor(__namedParameters: OrpcSocketErrorOptionsType) {};
status: void;
defined: void;
data: void;
code: void;
topic: null | string;
shape: null | OrpcErrorType<Code, Data>;
payload: unknown;
cause: unknown;
}
Parameters
| Name | Type | Description |
|---|---|---|
| __namedParameters | |
Properties
cause
Overrides Error.cause
The
ORPCError
sent by the server, or the error of the transport or the decoding
Source
Type
unknown
shape
Error sent by the server,
null
when the failure did not come from a procedure
Source
Type
null | OrpcErrorType<Code, Data>
topic
Topic of the failed subscription,
null
when the message can't be matched to a subscription
Source
Type
null | string
Usage
socket.onError(({ error }) => {
if (error instanceof OrpcSocketError && error.defined && error.code === "UNAUTHORIZED") {
logout();
}
});

