react-native-okhi
    Preparing search index...

    Class OkHiException

    Error class for OkHi operations.

    All OkHi functions that can fail will throw an OkHiException. Use the static code constants for type-safe error handling in switch statements.

    import * as OkHi from 'react-native-okhi';

    try {
    const result = await OkHi.startDigitalAddressVerification();
    } catch (error) {
    if (error instanceof OkHi.OkHiException) {
    switch (error.code) {
    case OkHi.OkHiException.USER_CLOSED:
    console.log('User cancelled the verification');
    break;
    case OkHi.OkHiException.NETWORK_ERROR:
    console.log('Network issue:', error.message);
    break;
    case OkHi.OkHiException.PERMISSION_DENIED:
    console.log('Permission denied:', error.message);
    break;
    default:
    console.log('Error:', error.code, error.message);
    }
    }
    }

    Hierarchy

    • Error
      • OkHiException
    Index

    Constructors

    Properties

    stackTraceLimit: number

    The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

    The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

    If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

    FATAL_EXIT: OkHiErrorCode = 'fatal_exit'

    A fatal error occurred that caused the SDK to exit unexpectedly.

    USER_CLOSED: OkHiErrorCode = 'user_closed'

    The user dismissed or closed the verification flow.

    UNKNOWN: OkHiErrorCode = 'unknown'

    An unknown or unexpected error occurred.

    NETWORK_ERROR: OkHiErrorCode = 'network_error'

    A network connectivity error occurred.

    PERMISSION_DENIED: OkHiErrorCode = 'permission_denied'

    Required permissions were not granted.

    SERVICE_UNAVAILABLE: OkHiErrorCode = 'service_unavailable'

    The OkHi service is temporarily unavailable.

    UNSUPPORTED_DEVICE: OkHiErrorCode = 'unsupported_device'

    The device is not supported (e.g., missing Play Services, unsupported platform).

    UNAUTHENTICATED: OkHiErrorCode = 'unauthenticated'

    Authentication failed. Call login() with valid credentials.

    INVALID_PHONE: OkHiErrorCode = 'invalid_phone'

    The phone number provided is invalid.

    Machine-readable error code. Use this for programmatic error handling with switch statements.

    if (error.code === OkHi.OkHiException.USER_CLOSED) {
    // Handle user cancellation
    }
    cause?: unknown
    name: string
    message: string
    stack?: string

    Methods

    • Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

      const myObject = {};
      Error.captureStackTrace(myObject);
      myObject.stack; // Similar to `new Error().stack`

      The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

      The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

      The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

      function a() {
      b();
      }

      function b() {
      c();
      }

      function c() {
      // Create an error without stack trace to avoid calculating the stack trace twice.
      const { stackTraceLimit } = Error;
      Error.stackTraceLimit = 0;
      const error = new Error();
      Error.stackTraceLimit = stackTraceLimit;

      // Capture the stack trace above function b
      Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
      throw error;
      }

      a();

      Parameters

      • targetObject: object
      • OptionalconstructorOpt: Function

      Returns void

    • Type guard to check if an error is an OkHiException.

      Parameters

      • error: unknown

        The error to check

      Returns error is OkHiException

      True if the error is an OkHiException

      try {
      await OkHi.startDigitalAddressVerification();
      } catch (error) {
      if (OkHi.OkHiException.isOkHiException(error)) {
      console.log(error.code, error.message);
      }
      }
    • Indicates whether the argument provided is a built-in Error instance or not.

      Parameters

      • error: unknown

      Returns error is Error