Skip to main content
Version: v10.0.0

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 null when 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"

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
NameTypeDescription
__namedParameters
OrpcSocketErrorOptionsType

Properties​

cause​

Overrides Error.cause

The ORPCError sent by the server, or the error of the transport or the decoding

Type
unknown

payload​

Input of the failed subscription

Type
unknown

shape​

Error sent by the server, null when the failure did not come from a procedure

Type
null | OrpcErrorType<Code, Data>

topic​

Topic of the failed subscription, null when the message can't be matched to a subscription

Type
null | string

code​

Type
void

data​

Type
void

defined​

Type
void

status​

Type
void

Usage​

socket.onError(({ error }) => {
if (error instanceof OrpcSocketError && error.defined && error.code === "UNAUTHORIZED") {
logout();
}
});