Commit f164d5a9 authored by Mygod's avatar Mygod

Refine start service failures

parent 06f23085
......@@ -410,11 +410,11 @@ object BaseService {
data.changeState(CONNECTED)
} catch (_: UnknownHostException) {
stopRunner(true, getString(R.string.invalid_server))
} catch (_: VpnService.NullConnectionException) {
stopRunner(true, getString(R.string.reboot_required))
} catch (exc: Throwable) {
printLog(exc)
stopRunner(true, "${getString(R.string.service_failed)}: ${exc.message}")
if (exc !is PluginManager.PluginNotFoundException && exc !is VpnService.NullConnectionException) {
printLog(exc)
}
stopRunner(true, "${getString(R.string.service_failed)}: ${exc.localizedMessage}")
}
}
return Service.START_NOT_STICKY
......
......@@ -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 {
BaseService.register(this)
......
......@@ -41,6 +41,10 @@ import java.io.File
import java.io.FileNotFoundException
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
* to publish or has published plugins for this app. You can obtain your public key by executing:
......@@ -128,8 +132,7 @@ object PluginManager {
// add other plugin types here
throw throwable
?: FileNotFoundException(app.getString(com.github.shadowsocks.core.R.string.plugin_unknown, options.id))
throw throwable ?: PluginNotFoundException(options.id)
}
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