Skip to content

getErrorDetailsAs

Casts bridge error details to the expected details type. Use it after checking the error code or error type when native code returns structured failure information.

Importing

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

Usage

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

type ValidationDetails = { field: string };
const details = getErrorDetailsAs<ValidationDetails>(response.error);

Parameters

NameTypeDescription
errorBridgeErrorError containing details.

Returns

The error details cast to TExpectedDetails, or null when the bridge error did not include details.

Type signature

ts
declare function getErrorDetailsAs<TExpectedDetails>(
    error: BridgeError
): TExpectedDetails | null;

All packages are released under the MIT License.