From 3ffca24908b7bda3c342fc095d9b83d3d7740075 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 24 Dec 2016 02:25:45 +0800 Subject: [PATCH] Handle error msg for no profile --- src/main/scala/com/github/shadowsocks/BaseService.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/BaseService.scala b/src/main/scala/com/github/shadowsocks/BaseService.scala index b2147047..3545d01d 100644 --- a/src/main/scala/com/github/shadowsocks/BaseService.scala +++ b/src/main/scala/com/github/shadowsocks/BaseService.scala @@ -107,9 +107,9 @@ trait BaseService extends Service { } } - override def use(profileId: Int): Unit = synchronized(if (profileId < 0) stopRunner(stopService = true) else { + override def use(profileId: Int): Unit = synchronized { val profile = app.profileManager.getProfile(profileId).orNull - if (profile == null) stopRunner(stopService = true) else state match { + if (profile == null) stopRunner(stopService = true, "Please select a profile.") else state match { // TODO: localize case State.STOPPED => if (checkProfile(profile)) startRunner(profile) case State.CONNECTED => if (profileId != BaseService.this.profile.id && checkProfile(profile)) { stopRunner(stopService = false) @@ -117,7 +117,7 @@ trait BaseService extends Service { } case _ => Log.w(BaseService.this.getClass.getSimpleName, "Illegal state when invoking use: " + state) } - }) + } override def useSync(profileId: Int): Unit = use(profileId) }