Force close app when exception occurs in FutureHelper.
This commit is contained in:
parent
a951b05965
commit
f5ee0996eb
1 changed files with 9 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
package com.nutomic.ensichat.core.util
|
||||
|
||||
import com.nutomic.ensichat.core.interfaces.Log
|
||||
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
|
||||
/**
|
||||
|
@ -9,11 +11,17 @@ import scala.concurrent.{ExecutionContext, Future}
|
|||
*/
|
||||
object FutureHelper {
|
||||
|
||||
private val Tag = "FutureHelper"
|
||||
|
||||
def apply[A](action: => A)(implicit executor: ExecutionContext): Future[A] = {
|
||||
val f = Future(action)
|
||||
f.onFailure {
|
||||
case e =>
|
||||
throw e
|
||||
// HACK: Android does not close app when crash occurs in background thread, and there's no
|
||||
// cross-platform way to execute on the foreground thread.
|
||||
// We use this to make sure exceptions are not hidden in the logs.
|
||||
Log.e(Tag, "Exception in Future", e)
|
||||
System.exit(-1)
|
||||
}
|
||||
f
|
||||
}
|
||||
|
|
Reference in a new issue