@@ -121,27 +121,14 @@ class ErrorPanelHelper(
121121 ErrorActivity .reportError(context, errorInfo)
122122 }
123123
124- errorTextView.setText(
125- when (errorInfo.throwable) {
126- is AgeRestrictedContentException -> R .string.restricted_video_no_stream
127- is GeographicRestrictionException -> R .string.georestricted_content
128- is PaidContentException -> R .string.paid_content
129- is PrivateContentException -> R .string.private_content
130- is SoundCloudGoPlusContentException -> R .string.soundcloud_go_plus_content
131- is YoutubeMusicPremiumContentException -> R .string.youtube_music_premium_content
132- is ContentNotAvailableException -> R .string.content_not_available
133- is ContentNotSupportedException -> R .string.content_not_supported
134- else -> {
135- // show retry button only for content which is not unavailable or unsupported
136- errorRetryButton.isVisible = true
137- if (errorInfo.throwable != null && errorInfo.throwable!! .isNetworkRelated) {
138- R .string.network_error
139- } else {
140- R .string.error_snackbar_message
141- }
142- }
143- }
144- )
124+ errorTextView.setText(getExceptionDescription(errorInfo.throwable))
125+
126+ if (errorInfo.throwable !is ContentNotAvailableException &&
127+ errorInfo.throwable !is ContentNotSupportedException
128+ ) {
129+ // show retry button only for content which is not unavailable or unsupported
130+ errorRetryButton.isVisible = true
131+ }
145132 }
146133
147134 setRootVisible()
@@ -189,5 +176,27 @@ class ErrorPanelHelper(
189176 companion object {
190177 val TAG : String = ErrorPanelHelper ::class .simpleName!!
191178 val DEBUG : Boolean = MainActivity .DEBUG
179+
180+ @StringRes
181+ public fun getExceptionDescription (throwable : Throwable ? ): Int {
182+ return when (throwable) {
183+ is AgeRestrictedContentException -> R .string.restricted_video_no_stream
184+ is GeographicRestrictionException -> R .string.georestricted_content
185+ is PaidContentException -> R .string.paid_content
186+ is PrivateContentException -> R .string.private_content
187+ is SoundCloudGoPlusContentException -> R .string.soundcloud_go_plus_content
188+ is YoutubeMusicPremiumContentException -> R .string.youtube_music_premium_content
189+ is ContentNotAvailableException -> R .string.content_not_available
190+ is ContentNotSupportedException -> R .string.content_not_supported
191+ else -> {
192+ // show retry button only for content which is not unavailable or unsupported
193+ if (throwable != null && throwable.isNetworkRelated) {
194+ R .string.network_error
195+ } else {
196+ R .string.error_snackbar_message
197+ }
198+ }
199+ }
200+ }
192201 }
193202}
0 commit comments