Repository: facebook/react
File: packages/shared/invokeGuardedCallbackImpl.js (JavaScript)

Code before:
          // eslint-disable-next-line react-internal/prod-error-codes
          error = new Error(
            "A cross-origin error was thrown. React doesn't have access to " +
              'the actual error object in development. ' +
              'See https://reactjs.org/link/crossorigin-error for more information.',
          );
        }
        this.onError(error);
      }

      // Remove our event listeners
      win.removeEventListener('error', handleWindowError);

      if (didCall) {
        return;
      } else {
        // Something went really wrong, and our event was not dispatched.
        // https://github.com/facebook/react/issues/16734
        // https://github.com/facebook/react/issues/16585
        // Fall back to the production implementation.
        restoreAfterDispatch();
        // we fall through and call the prod version instead
      }
    }
    // We only get here if we are in an environment that either does not support the browser
    // variant or we had trouble getting the brwoser to emit the error.
    // $FlowFixMe[method-unbinding]
    const funcArgs = Array.prototype.slice.call(arguments, 3);
    try {
      // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing.
      func.apply(context, funcArgs);
    } catch (error) {
      this.onError(error);
    }
  } else {
    // $FlowFixMe[method-unbinding]
    const funcArgs = Array.prototype.slice.call(arguments, 3);
    try {
      // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing.
      func.apply(context, funcArgs);
    } catch (error) {
      this.onError(error);
    }
  }
}


Review comment (suggestion):
```suggestion
    // variant or we had trouble getting the browser to emit the error.
```

Code after:
              'the actual error object in development. ' +
              'See https://reactjs.org/link/crossorigin-error for more information.',
          );
        }
        this.onError(error);
      }

      // Remove our event listeners
      window.removeEventListener('error', handleWindowError);

      if (didCall) {
        return;
      } else {
        // Something went really wrong, and our event was not dispatched.
        // https://github.com/facebook/react/issues/16734
        // https://github.com/facebook/react/issues/16585
        // Fall back to the production implementation.
        restoreAfterDispatch();
        // we fall through and call the prod version instead
      }
    }
    // We only get here if we are in an environment that either does not support the browser
    // variant or we had trouble getting the browser to emit the error.
    // $FlowFixMe[method-unbinding]
    const funcArgs = Array.prototype.slice.call(arguments, 3);
    try {
      // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing.
      func.apply(context, funcArgs);
    } catch (error) {
      this.onError(error);
    }
  } else {
    // $FlowFixMe[method-unbinding]
    const funcArgs = Array.prototype.slice.call(arguments, 3);
    try {
      // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing.
      func.apply(context, funcArgs);
    } catch (error) {
      this.onError(error);
    }
  }
}