@@ -5,25 +5,17 @@ import io.agora.flat.R
55import io.agora.flat.common.FlatErrorCode
66import io.agora.flat.common.FlatException
77import io.agora.flat.common.FlatNetException
8- import io.agora.flat.common.FlatRtcException
9- import io.agora.flat.common.FlatRtmException
108import io.agora.flat.di.GlobalInstanceProvider
119
1210object FlatErrorHandler {
1311 fun getErrorStr (context : Context , error : Throwable ? , defaultValue : String = "Unhandled exceptions"): String {
14- return if (error is FlatException ) {
15- when (error) {
12+ if (error is FlatException ) {
13+ return when (error) {
1614 is FlatNetException -> getNetErrorString(context, error)
17-
18- is FlatRtcException -> defaultValue
19-
20- is FlatRtmException -> defaultValue
21-
22- else -> defaultValue
15+ else -> error.message ? : defaultValue
2316 }
24- } else {
25- defaultValue
2617 }
18+ return error?.message ? : defaultValue
2719 }
2820
2921 private fun getNetErrorString (context : Context , error : FlatNetException ): String {
@@ -59,12 +51,11 @@ object FlatErrorHandler {
5951 FlatErrorCode .Web .RoomLimit -> context.getString(R .string.pay_room_users_limit)
6052 FlatErrorCode .Web .RoomExpired -> context.getString(R .string.pay_room_expired)
6153 FlatErrorCode .Web .RoomNotBegin -> context.getString(
62- R .string.room_not_started,
63- appKVCenter.getJoinEarly()
54+ R .string.room_not_started, appKVCenter.getJoinEarly()
6455 )
56+
6557 FlatErrorCode .Web .RoomNotBeginAndAddList -> context.getString(
66- R .string.room_not_started_added,
67- appKVCenter.getJoinEarly()
58+ R .string.room_not_started_added, appKVCenter.getJoinEarly()
6859 )
6960
7061 FlatErrorCode .Web .RoomCreateLimit -> context.getString(R .string.pay_room_reached_limit)
0 commit comments