Skip to content

BridgeError

Describes a bridge error returned by either the native side or the transport layer. The type field separates native failures from JavaScript bridge failures, while code and details carry more specific error information.

Importing

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

Usage

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

type ValidationError = BridgeError<'VALIDATION_ERROR', { field: string }>;

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 BridgeError<TCode extends string = string, TDetails = unknown> = {
    type: 'native' | 'transport';
    code: TCode;
    message: string | null;
    details: TDetails | null;
};

All packages are released under the MIT License.