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
This commit is contained in:
David Vacca 2019-12-11 18:35:55 -08:00 коммит произвёл Facebook Github Bot
Родитель b28cd93b68
Коммит f6edeccf20
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -124,14 +124,14 @@ public class ReactContext extends ContextWrapper {
*/
public <T extends JavaScriptModule> T getJSModule(Class<T> 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 <T extends NativeModule> boolean hasNativeModule(Class<T> 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 extends NativeModule> T getNativeModule(Class<T> 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);
}
}