|
|
@@ -5,6 +5,9 @@ import androidx.annotation.StringRes
|
|
|
import com.adealink.frame.aab.util.getCompatString
|
|
|
import com.adealink.frame.base.AppBase
|
|
|
import com.adealink.frame.base.IError
|
|
|
+import com.adealink.frame.base.NetworkHttpExecuteError
|
|
|
+import com.adealink.frame.base.NetworkHttpResBodyNullError
|
|
|
+import com.adealink.frame.base.NetworkHttpStatusNoSuccessError
|
|
|
import com.adealink.frame.base.Rlt
|
|
|
import com.adealink.frame.util.AppUtil
|
|
|
import com.adealink.frame.util.runOnUiThread
|
|
|
@@ -60,27 +63,8 @@ fun showFailedToast(rlt: Rlt<*>) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fun showToast(error: IError, default: CharSequence? = null) {
|
|
|
- if (error.msg.isNotEmpty()) {
|
|
|
- if (AppBase.isRelease) {
|
|
|
- //正式包不展示错误码
|
|
|
- showToast(error.msg)
|
|
|
- } else {
|
|
|
- showToast(getCompatString(R.string.commonui_error_msg, error.msg, error.serverCode))
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if (error.exception?.message?.isNotBlank() == true) {
|
|
|
- showToast(error.exception!!.message!!)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if (default.isNullOrEmpty()) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- showToast(default)
|
|
|
+fun showToast(error: IError, default: CharSequence = getCompatString(R.string.common_failed)) {
|
|
|
+ showToast(getFailedMsg(error, default.toString()))
|
|
|
}
|
|
|
|
|
|
fun getFailedMsg(error: IError, default: String? = getCompatString(R.string.common_failed)): String {
|
|
|
@@ -92,9 +76,18 @@ fun getFailedMsg(error: IError, default: String? = getCompatString(R.string.comm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- val exceptionMsg = error.exception?.message
|
|
|
- if (exceptionMsg?.isNotBlank() == true) {
|
|
|
- return exceptionMsg
|
|
|
+ //网络错误
|
|
|
+ if (error is NetworkHttpStatusNoSuccessError || error is NetworkHttpExecuteError || error is NetworkHttpResBodyNullError) {
|
|
|
+ return if (AppBase.isRelease) {
|
|
|
+ getCompatString(R.string.common_net_error)
|
|
|
+ } else {
|
|
|
+ "${getCompatString(R.string.common_net_error)} ${error.exception?.message}"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ val exceptionMsg = error.exception?.message
|
|
|
+ if (exceptionMsg?.isNotBlank() == true) {
|
|
|
+ return exceptionMsg
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (default.isNullOrEmpty()) {
|