Skip to content

Commit

Permalink
Invoke error display on main thread to avoid crashing
Browse files Browse the repository at this point in the history
Failing to run the view change on the main thread may cause a
CalledFromWrongThread exception as the view may not have been created
from a thread in the IO pool.
  • Loading branch information
Johnny-Malizia committed Sep 8, 2021
1 parent 1f50d29 commit 8ea5f4e
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -47,7 +47,9 @@ open class MobileAppIntegrationPresenterBase constructor(
integrationUseCase.registerDevice(deviceRegistration)
} catch (e: Exception) {
Log.e(TAG, "Unable to register with Home Assistant", e)
view.showError()
withContext(mainScope.coroutineContext) {
view.showError()
}
return@launch
}
view.deviceRegistered()
Expand Down

0 comments on commit 8ea5f4e

Please sign in to comment.