Commit f164d5a9 authored by Mygod's avatar Mygod

Refine start service failures

parent 06f23085
...@@ -410,11 +410,11 @@ object BaseService { ...@@ -410,11 +410,11 @@ object BaseService {
data.changeState(CONNECTED) data.changeState(CONNECTED)
} catch (_: UnknownHostException) { } catch (_: UnknownHostException) {
stopRunner(true, getString(R.string.invalid_server)) stopRunner(true, getString(R.string.invalid_server))
} catch (_: VpnService.NullConnectionException) {
stopRunner(true, getString(R.string.reboot_required))
} catch (exc: Throwable) { } catch (exc: Throwable) {
printLog(exc) if (exc !is PluginManager.PluginNotFoundException && exc !is VpnService.NullConnectionException) {
stopRunner(true, "${getString(R.string.service_failed)}: ${exc.message}") printLog(exc)
}
stopRunner(true, "${getString(R.string.service_failed)}: ${exc.localizedMessage}")
} }
} }
return Service.START_NOT_STICKY return Service.START_NOT_STICKY
......
...@@ -104,7 +104,9 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface { ...@@ -104,7 +104,9 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
} }
} }
} }
class NullConnectionException : NullPointerException() inner class NullConnectionException : NullPointerException() {
override fun getLocalizedMessage() = getString(R.string.reboot_required)
}
init { init {
BaseService.register(this) BaseService.register(this)
......
...@@ -41,6 +41,10 @@ import java.io.File ...@@ -41,6 +41,10 @@ import java.io.File
import java.io.FileNotFoundException import java.io.FileNotFoundException
object PluginManager { object PluginManager {
class PluginNotFoundException(private val plugin: String) : FileNotFoundException(plugin) {
override fun getLocalizedMessage() = app.getString(com.github.shadowsocks.core.R.string.plugin_unknown, plugin)
}
/** /**
* Trusted signatures by the app. Third-party fork should add their public key to their fork if the developer wishes * Trusted signatures by the app. Third-party fork should add their public key to their fork if the developer wishes
* to publish or has published plugins for this app. You can obtain your public key by executing: * to publish or has published plugins for this app. You can obtain your public key by executing:
...@@ -128,8 +132,7 @@ object PluginManager { ...@@ -128,8 +132,7 @@ object PluginManager {
// add other plugin types here // add other plugin types here
throw throwable throw throwable ?: PluginNotFoundException(options.id)
?: FileNotFoundException(app.getString(com.github.shadowsocks.core.R.string.plugin_unknown, options.id))
} }
private fun initNative(options: PluginOptions): String? { private fun initNative(options: PluginOptions): String? {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment