From f6edeccf203257d373bceacfaef9077d824dcf00 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Wed, 11 Dec 2019 18:35:55 -0800 Subject: [PATCH] Refactor ReactContext to use IllegalStateException instead of RuntimeException Summary: This diff refactors ReactContext to use IllegalStateException instead of RuntimeException when applicable. Changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D18901845 fbshipit-source-id: 51ec36824c8402fa2c17e76c55578be44ec8aa15 --- .../java/com/facebook/react/bridge/ReactContext.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java index bdae0b2f6d8..102f1964160 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -124,14 +124,14 @@ public class ReactContext extends ContextWrapper { */ public T getJSModule(Class jsInterface) { if (mCatalystInstance == null) { - throw new RuntimeException(EARLY_JS_ACCESS_EXCEPTION_MESSAGE); + throw new IllegalStateException(EARLY_JS_ACCESS_EXCEPTION_MESSAGE); } return mCatalystInstance.getJSModule(jsInterface); } public boolean hasNativeModule(Class nativeModuleInterface) { if (mCatalystInstance == null) { - throw new RuntimeException( + throw new IllegalStateException( "Trying to call native module before CatalystInstance has been set!"); } return mCatalystInstance.hasNativeModule(nativeModuleInterface); @@ -140,7 +140,7 @@ public class ReactContext extends ContextWrapper { /** @return the instance of the specified module interface associated with this ReactContext. */ public T getNativeModule(Class nativeModuleInterface) { if (mCatalystInstance == null) { - throw new RuntimeException( + throw new IllegalStateException( "Trying to call native module before CatalystInstance has been set!"); } return mCatalystInstance.getNativeModule(nativeModuleInterface); @@ -186,7 +186,7 @@ public class ReactContext extends ContextWrapper { }); break; default: - throw new RuntimeException("Unhandled lifecycle state."); + throw new IllegalStateException("Unhandled lifecycle state."); } } } @@ -367,7 +367,7 @@ public class ReactContext extends ContextWrapper { + " - hasExceptionHandler: " + hasExceptionHandler, e); - throw new RuntimeException(e); + throw new IllegalStateException(e); } }