Skip to content

Commit 7b9c736

Browse files
committed
docs: add JSDoc for getError helper in createNetworkClient
Add comprehensive documentation for the getError function that extracts errors from Cockatiel's FailureReason type in circuit breaker event handlers. Documents both possible shapes of the FailureReason object.
1 parent 321ff7c commit 7b9c736

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/network-controller/src/create-network-client.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,23 @@ function createRpcServiceChain({
213213
logger,
214214
}));
215215

216+
/**
217+
* Extracts the error from Cockatiel's `FailureReason` type received in
218+
* circuit breaker event handlers.
219+
*
220+
* The `FailureReason` object can have two possible shapes:
221+
* - `{ error: Error }` - When the RPC service throws an error (the common
222+
* case for RPC failures).
223+
* - `{ value: T }` - When the RPC service returns a value that the retry
224+
* filter policy considers a failure.
225+
*
226+
* @param value - The event data object from the circuit breaker event
227+
* listener (after destructuring known properties like `endpointUrl` and
228+
* `primaryEndpointUrl`). This represents Cockatiel's `FailureReason` type.
229+
* @returns The error or failure value, or `undefined` if neither property
230+
* exists (which shouldn't happen in practice unless the circuit breaker is
231+
* manually isolated).
232+
*/
216233
const getError = (value: object) => {
217234
if ('error' in value) {
218235
return value.error;

0 commit comments

Comments
 (0)