INNER CODE UNIT · JavaScript

noop

a7ul/react-native-exception-handler · index.js:5

const noop = () => { };

export const setJSExceptionHandler = (customHandler = noop, allowedInDevMode = false) => {
  if (typeof allowedInDevMode !== "boolean" || typeof customHandler !== "function") {
    console.log("setJSExceptionHandler is called with wrong argument types.. first argument should be callback function and second argument is optional should be a boolean");
    console.log("Not setting the JS handler .. please fix setJSExceptionHandler call");
    return;
  }
  const allowed = allowedInDevMode ? true : !__DEV__;
  if (allowed) {
    global.ErrorUtils.setGlobalHandler(customHandler);
    const consoleError = console.error;
    console.error = (...args) => {
      global.ErrorUtils.reportError(...args);
      consoleError(...args);
    };
  } else {
    console.log("Skipping setJSExceptionHandler: Reason: In DEV mode and allowedInDevMode = false");

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…