Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
152a71f0
Commit
152a71f0
authored
Dec 12, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化Http错误提示
parent
3889cf49
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
src/main/java/tech/starwin/impl/HttpObserver.java
+7
-7
src/main/java/tech/starwin/utils/LoginManager.java
+1
-1
No files found.
src/main/java/tech/starwin/impl/HttpObserver.java
View file @
152a71f0
...
...
@@ -49,26 +49,26 @@ public abstract class HttpObserver<T> implements Observer<T> {
String
msg
=
throwable
.
getMessage
();
try
{
if
(
throwable
!=
null
)
{
if
(
is
Http
Error
(
msg
))
{
if
(
is
Network
Error
(
msg
))
{
onError
(
Error
.
HTTP_ERROR
,
LibConfig
.
getContext
().
getString
(
R
.
string
.
text_net_error
));
}
else
if
(
throwable
instanceof
HttpException
)
{
HttpException
exception
=
(
HttpException
)
throwable
;
if
(!
isCanHandle
(
exception
))
{
String
body
=
exception
.
response
().
errorBody
().
string
();
ResponseErrorBody
responseErrorBody
=
new
Gson
().
fromJson
(
body
,
ResponseErrorBody
.
class
);
onError
(
Error
.
SERVER_ERROR
,
responseErrorBody
.
getMessage
());
onError
(
Error
.
SERVER_ERROR
,
"Server Exception: "
+
responseErrorBody
.
getMessage
());
}
}
else
if
(
msg
.
contains
(
"java.lang.IllegalStateException"
))
{
onError
(
Error
.
APP_ERROR
,
LibConfig
.
getContext
().
getString
(
R
.
string
.
text_app_error
)
);
onError
(
Error
.
APP_ERROR
,
"Program Exception"
);
}
else
if
(
msg
.
contains
(
"body is null"
))
{
onSuccess
(
null
);
}
else
{
onError
(
Error
.
UNKNOW
,
msg
);
onError
(
Error
.
UNKNOW
,
"Unknow Exception: "
+
msg
);
}
}
}
catch
(
Throwable
e
)
{
onError
(
Error
.
APP_ERROR
,
msg
);
onError
(
Error
.
APP_ERROR
,
"Program Exception: "
+
msg
);
}
if
(
disposable
!=
null
)
disposable
.
dispose
();
...
...
@@ -99,7 +99,7 @@ public abstract class HttpObserver<T> implements Observer<T> {
BasicAck
result
=
gson
.
fromJson
(
exception
.
response
().
body
().
toString
(),
BasicAck
.
class
);
UpdateBean
updateBean
=
gson
.
fromJson
(
result
.
getData
(),
UpdateBean
.
class
);
EventBus
.
getDefault
().
post
(
updateBean
);
}
else
{
}
else
{
EventBus
.
getDefault
().
post
(
new
UpdateBean
());
}
return
true
;
...
...
@@ -118,7 +118,7 @@ public abstract class HttpObserver<T> implements Observer<T> {
/**
* 链路错误
*/
private
boolean
is
Http
Error
(
String
msg
)
{
private
boolean
is
Network
Error
(
String
msg
)
{
String
[]
errorArray
=
new
String
[]{
"timeout"
,
"java.net.ConnectException"
,
...
...
src/main/java/tech/starwin/utils/LoginManager.java
View file @
152a71f0
...
...
@@ -60,7 +60,7 @@ public class LoginManager {
PreferencesManager
.
get
().
clearLoginInfo
();
tokenInfo
=
null
;
//广播通知
LibConfig
.
getContext
().
sendBroadcast
(
new
Intent
(
ActionEnum
.
LOGIN_INVALID
.
value
())
);
EventBus
.
getDefault
().
post
(
ActionEnum
.
LOGIN_INVALID
);
if
(
LibConfig
.
isDefaultLoginMode
())
{
//跳转登录界面
...
...
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