Skip to content

Commit

Permalink
fix: resolves #1103 - crash on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
gmiszewski-intent committed Oct 10, 2023
1 parent 789b9ab commit 95ae38b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion android/src/main/java/com/bleplx/BlePlxModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,36 @@
import com.bleplx.converter.ServiceToJsObjectConverter;
import com.bleplx.utils.ReadableArrayConverter;
import com.bleplx.utils.SafePromise;
import com.polidea.rxandroidble2.internal.RxBleLog;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import android.app.Activity;

import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.plugins.RxJavaPlugins;

@ReactModule(name = BlePlxModule.NAME)
public class BlePlxModule extends ReactContextBaseJavaModule {
public static final String NAME = "BlePlx";

public BlePlxModule(ReactApplicationContext reactContext) {
super(reactContext);
RxJavaPlugins.setErrorHandler(throwable -> {
if (throwable instanceof UndeliverableException) {
RxBleLog.e("Handle all unhandled exceptions from RxJava: " + throwable.getMessage());
} else {
Thread currentThread = Thread.currentThread();
Thread.UncaughtExceptionHandler errorHandler = currentThread.getUncaughtExceptionHandler();
if (errorHandler != null) {
errorHandler.uncaughtException(currentThread, throwable);
}
}
});
}

@Override
Expand Down

0 comments on commit 95ae38b

Please sign in to comment.