Skip to content

Commit

Permalink
fix: catch InternalError when starting okhttp thread during runtime s…
Browse files Browse the repository at this point in the history
…hutdown.
  • Loading branch information
cpacm committed Sep 12, 2023
1 parent ee8a2f0 commit e6c7c73
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/**
* 1.用于OkHttp防止部分机型关闭网络权限导致崩溃(特定Rom对permission的管理问题或Root后关闭权限),转为IO异常回调失败
* 2.加强保护,将所有异常转为io异常回调失败,避免部分okhttp内部错误导致异常
* 3.捕获错误
*/
public class SecurityExceptionInterceptor implements Interceptor {
private static final String TAG = "SecurityExceptionInterceptor";
Expand All @@ -33,9 +34,9 @@ public class SecurityExceptionInterceptor implements Interceptor {
public Response intercept(Chain chain) throws IOException {
try {
return chain.proceed(chain.request());
} catch (Exception e) {
Logger.e(TAG, "HTTP FAILED: " + e.getMessage());
throw e;
} catch (Throwable e) {
Logger.e(TAG, "Failed due to an Exception: " + e.getClass().getName() + " with message " + e.getMessage());
throw new IOException(e.getMessage());
}
}
}

0 comments on commit e6c7c73

Please sign in to comment.