Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
9a3ed94f
Commit
9a3ed94f
authored
Oct 12, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine error handling in services
parent
0191d1d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
12 deletions
+5
-12
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+3
-2
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+2
-10
No files found.
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
9a3ed94f
...
...
@@ -62,6 +62,7 @@ trait BaseService extends Service {
case
class
NameNotResolvedException
()
extends
IOException
case
class
KcpcliParseException
(
cause
:
Throwable
)
extends
Exception
(
cause
)
case
class
NullConnectionException
()
extends
NullPointerException
var
timer
:
Timer
=
_
var
trafficMonitorThread
:
TrafficMonitorThread
=
_
...
...
@@ -141,8 +142,7 @@ trait BaseService extends Service {
}
def
checkProfile
(
profile
:
Profile
)
=
if
(
TextUtils
.
isEmpty
(
profile
.
host
)
||
TextUtils
.
isEmpty
(
profile
.
password
))
{
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
proxy_empty
))
stopRunner
(
true
)
stopRunner
(
true
,
getString
(
R
.
string
.
proxy_empty
))
false
}
else
true
...
...
@@ -200,6 +200,7 @@ trait BaseService extends Service {
case
_:
NameNotResolvedException
=>
stopRunner
(
true
,
getString
(
R
.
string
.
invalid_server
))
case
exc
:
KcpcliParseException
=>
stopRunner
(
true
,
getString
(
R
.
string
.
service_failed
)
+
": "
+
exc
.
cause
.
getMessage
)
case
_:
NullConnectionException
=>
stopRunner
(
true
,
getString
(
R
.
string
.
reboot_required
))
case
exc
:
Throwable
=>
stopRunner
(
true
,
getString
(
R
.
string
.
service_failed
)
+
": "
+
exc
.
getMessage
)
exc
.
printStackTrace
()
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
9a3ed94f
...
...
@@ -379,16 +379,8 @@ class ShadowsocksVpnService extends VpnService with BaseService {
builder
.
addRoute
(
"8.8.0.0"
,
16
)
try
{
conn
=
builder
.
establish
()
if
(
conn
==
null
)
changeState
(
State
.
STOPPED
,
getString
(
R
.
string
.
reboot_required
))
}
catch
{
case
ex
:
Exception
=>
ex
.
printStackTrace
()
app
.
track
(
ex
)
stopRunner
(
true
,
ex
.
getMessage
)
return
-
1
}
conn
=
builder
.
establish
()
if
(
conn
==
null
)
throw
new
NullConnectionException
val
fd
=
conn
.
getFd
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment