Skip to content

Commit 8b449c2

Browse files
mateoguzmanafacebook-github-bot
authored andcommitted
Migrate GuardedRunnable to Kotlin (facebook#50259)
Summary: Migrate com.facebook.react.bridge.GuardedRunnable to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.bridge.GuardedRunnable to Kotlin Pull Request resolved: facebook#50259 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: javache Differential Revision: D71846384 Pulled By: Abbondanzo fbshipit-source-id: b465ce107f9a32e273442644ef6079347fe7e401
1 parent c372dc1 commit 8b449c2

File tree

2 files changed

+26
-36
lines changed

2 files changed

+26
-36
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/GuardedRunnable.java

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.bridge
9+
10+
/**
11+
* Abstract base for a Runnable that should have any RuntimeExceptions it throws handled by the
12+
* [JSExceptionHandler] registered if the app is in dev mode.
13+
*/
14+
public abstract class GuardedRunnable(private val exceptionHandler: JSExceptionHandler) : Runnable {
15+
public constructor(reactContext: ReactContext) : this(reactContext.exceptionHandler)
16+
17+
final override fun run() {
18+
try {
19+
runGuarded()
20+
} catch (e: RuntimeException) {
21+
exceptionHandler.handleException(e)
22+
}
23+
}
24+
25+
public abstract fun runGuarded()
26+
}

0 commit comments

Comments
 (0)