From f1601896632ad1422ac10aa59865dc5ac9716dcd Mon Sep 17 00:00:00 2001 From: Mygod Date: Mon, 13 Aug 2018 02:13:36 +0800 Subject: [PATCH] Catch IOException --- .../main/java/be/mygod/vpnhotspot/manage/TetherManager.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt index 53677ca3..0c1f55b3 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt @@ -25,6 +25,7 @@ import be.mygod.vpnhotspot.net.TetheringManager import be.mygod.vpnhotspot.net.wifi.WifiApManager import be.mygod.vpnhotspot.widget.SmartSnackbar import com.crashlytics.android.Crashlytics +import java.io.IOException import java.lang.reflect.InvocationTargetException sealed class TetherManager(protected val parent: TetheringFragment) : Manager(), @@ -57,6 +58,11 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(), val started = manager.isStarted try { if (started) manager.stop() else manager.start() + } catch (e: IOException) { + e.printStackTrace() + Crashlytics.logException(e) + Toast.makeText(mainActivity, e.localizedMessage, Toast.LENGTH_LONG).show() + ManageBar.start(itemView.context) } catch (e: InvocationTargetException) { e.printStackTrace() Crashlytics.logException(e) @@ -64,7 +70,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(), while (cause != null) { cause = cause.cause if (cause != null && cause !is InvocationTargetException) { - Toast.makeText(mainActivity, cause.message.toString(), Toast.LENGTH_LONG).show() + Toast.makeText(mainActivity, cause.localizedMessage, Toast.LENGTH_LONG).show() ManageBar.start(itemView.context) break }