npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-instantpay-exception-handler

v1.0.1

Published

A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions. The module helps prevent abrupt crashing of RN Apps without a graceful message to the user.

Downloads

14

Readme

react-native-instantpay-exception-handler

A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions. The module helps prevent abrupt crashing of RN Apps without a graceful message to the user.

Installation

npm install react-native-instantpay-exception-handler

PLEASE READ BEFORE GOING TO USAGE SECTION

In a React Native app, errors can be categorized into two types:

  • JS_Exceptions: These are errors generated by your JavaScript code, including all your React components.
  • Native_Exceptions: These are errors produced by native modules.

Unhandled exceptions can leave the app in a critical state.

For JS_Exceptions, you can catch unhandled errors and perform tasks such as displaying alerts or popups, cleaning up resources, or even hitting an API to notify the development team before closing the app.

For Native_Exceptions, the situation is more severe. Although you can catch these unhandled errors and perform tasks like cleanup, logging out, or notifying the development team via an API, you cannot interact with the JS UI layer (e.g., showing a JS alert box). Instead, you must handle any UI-related actions using native methods provided by the module in the respective native codebases for iOS and Android. The module does come with default handlers that provide basic error popups, which you can customize. See the CUSTOMIZATION section for more details.

Usage

To catch JS_Exceptions

import RNException from 'react-native-instantpay-exception-handler';

// ...

.
.
// For most use cases:
// registering the error handler (maybe u can do this in the index.android.js or index.ios.js)
RNException.setJSExceptionHandler((error, isFatal) => {
  // This is your custom global error handler
  // You do stuff like show an error dialog
  // or hit google analytics to track crashes
  // or hit a custom api to inform the dev team.
});

//=================================================
// ADVANCED use case:
const exceptionhandler = (error, isFatal) => {
  // your error handler function
};

RNException.setJSExceptionHandler(exceptionhandler, allowInDevMode);
// - exceptionhandler is the exception handler function
// - allowInDevMode is an optional parameter is a boolean.
//   If set to true the handler to be called in place of RED screen
//   in development mode also.

// getJSExceptionHandler gives the currently set JS exception handler
const currentHandler = RNException.getJSExceptionHandler();

To catch Native_Exceptions

import RNException from 'react-native-instantpay-exception-handler';

//For most use cases:
RNException.setNativeExceptionHandler((exceptionString) => {
  // This is your custom global error handler
  // You do stuff likehit google analytics to track crashes.
  // or hit a custom api to inform the dev team.
  //NOTE: alert or showing any UI change via JS
  //WILL NOT WORK in case of NATIVE ERRORS.
});

//====================================================
// ADVANCED use case:
const exceptionhandler = (exceptionString) => {
  // your exception handler code here
};

RNException.setNativeExceptionHandler(
    exceptionhandler,
    forceAppQuit,
    executeDefaultHandler
);
// - exceptionhandler is the exception handler function
// - forceAppQuit is an optional ANDROID specific parameter that defines
//    if the app should be force quit on error.  default value is true.
//    To see usecase check the common issues section.
// - executeDefaultHandler is an optional boolean (both IOS, ANDROID)
//    It executes previous exception handlers if set by some other module.
//    It will come handy when you use any other crash analytics module along with this one
//    Default value is set to false. Set to true if you are using other analytics modules.

It is recommended you set both the handlers. NOTE: setNativeExceptionHandler only works in bundled mode - it will show the red screen when applied to dev mode.

Use Cases In Android

Open up android/app/src/main/java/[...]/MainApplication.java

  • Add import com.instantpayexceptionhandler.InstantpayExceptionHandlerModule to the imports at the top of the file
  • Add below code inside onCreate() method
InstantpayExceptionHandlerModule.setAplicationContext = this
InstantpayExceptionHandlerModule.catchNativeException()

License

MIT


Created By Instantpay