Skip to content

BridgeFailure

Represents a failed bridge response. The ok: false discriminator lets TypeScript narrow the response and expose the structured error object.

Importing

ts
import type { BridgeFailure } from '@almighty-shogun/webkit-native-bridge'

Usage

ts
import type { BridgeFailure } from '@almighty-shogun/webkit-native-bridge'

const failure: BridgeFailure<'TIMEOUT'> = {
    ok: false,
    message: 'Timed out',
    error: { type: 'transport', code: 'TIMEOUT', message: 'Timed out', details: null }
}

Parameters

NameDescription
TCodeError code union for the failure. Defaults to string.
TDetailsOptional structured details returned with the error. Defaults to unknown.

Returns

A TypeScript type for native bridge APIs. It is erased at runtime and is used only by TypeScript to describe the shape of values passed to or returned from the package APIs.

Type signature

ts
type BridgeFailure<
    TCode extends string = string,
    TDetails = unknown
> = {
    ok: false;
    message: string | null;
    error: BridgeError<TCode, TDetails>;
};

All packages are released under the MIT License.