UNPKG

react-native-unit-components

Version:

Unit React Native components

24 lines 878 B
/* eslint-disable @typescript-eslint/no-explicit-any */ import { UNVPErrorType } from './types'; export const isUNVPError = error => { return 'code' in error && 'description' in error && 'type' in error && isUNVPErrorType(error.type) && 'correlationId' in error; }; const isUNVPErrorType = type => { return Object.values(UNVPErrorType).includes(type); }; export const isUNNativePromiseReject = error => { return 'code' in error && 'message' in error; }; export const promiseRejectToUNVPErrorType = error => { // validate the shape of a promise reject we get from iOS/Android native if (!isUNNativePromiseReject(error)) { return null; } const parsedError = JSON.parse(error.message); // validate the shape of an error we get from VDE SDK if (!isUNVPError(parsedError)) { return null; } return parsedError.type; }; //# sourceMappingURL=helpers.js.map