ChemPal Documentation - v1.17.0
    Preparing search index...

    Function isExpectedAbort

    • True when something stopped because the search was deliberately aborted: an AbortError, or one of the bare SEARCH_ABORT_REASON strings that a fetch rejects with when controller.abort(reason) is given a string. Use it to log such stops at debug.

      Parameters

      • error: unknown

        Whatever was thrown or rejected with

      Returns boolean

      true for an expected stop, false for a real failure

      isExpectedAbort('user_aborted');                       // true
      isExpectedAbort('time_budget_exceeded'); // true
      isExpectedAbort(new DOMException('x', 'AbortError')); // true
      isExpectedAbort(new TypeError('bad response')); // false
      export function isExpectedAbort(error: unknown): boolean {
      if (isAbortError(error)) {
      return true;
      }
      return typeof error === 'string' && Object.values<string>(SEARCH_ABORT_REASON).includes(error);
      }