@@ -104,6 +104,21 @@ class ErrorInfo(
104104 action : UserAction ?
105105 ): Int {
106106 return when {
107+ // player exceptions
108+ // some may be IOException, so do these checks before isNetworkRelated!
109+ throwable is ExoPlaybackException -> {
110+ val cause = throwable.cause
111+ when {
112+ cause is HttpDataSource .InvalidResponseCodeException && cause.responseCode == 403 -> R .string.player_error_403
113+ cause is Loader .UnexpectedLoaderException && cause.cause is ExtractionException -> getMessageStringId(throwable, action)
114+ throwable.type == ExoPlaybackException .TYPE_SOURCE -> R .string.player_stream_failure
115+ throwable.type == ExoPlaybackException .TYPE_UNEXPECTED -> R .string.player_recoverable_failure
116+ else -> R .string.player_unrecoverable_failure
117+ }
118+ }
119+ throwable is FailedMediaSource .FailedMediaSourceException -> getMessageStringId(throwable.cause, action)
120+ throwable is PlaybackResolver .ResolverException -> R .string.player_stream_failure
121+
107122 // content not available exceptions
108123 throwable is AccountTerminatedException -> R .string.account_terminated
109124 throwable is AgeRestrictedContentException -> R .string.restricted_video_no_stream
@@ -116,30 +131,18 @@ class ErrorInfo(
116131 throwable is YoutubeSignInConfirmNotBotException -> R .string.youtube_sign_in_confirm_not_bot_error
117132 throwable is ContentNotAvailableException -> R .string.content_not_available
118133
134+ // other extractor exceptions
135+ throwable is ContentNotSupportedException -> R .string.content_not_supported
119136 // ReCaptchas should have already been handled elsewhere,
120137 // but return an error message here just in case
121138 throwable is ReCaptchaException -> R .string.recaptcha_request_toast
122-
123- // other extractor exceptions
124- throwable is ContentNotSupportedException -> R .string.content_not_supported
139+ // test this at the end as many exceptions could be a subclass of IOException
125140 throwable != null && throwable.isNetworkRelated -> R .string.network_error
141+ // an extraction exception unrelated to the network
142+ // is likely an issue with parsing the website
126143 throwable is ExtractionException -> R .string.parsing_error
127144
128- // player exceptions
129- throwable is ExoPlaybackException -> {
130- val cause = throwable.cause
131- when {
132- cause is HttpDataSource .InvalidResponseCodeException && cause.responseCode == 403 -> R .string.player_error_403
133- cause is Loader .UnexpectedLoaderException && cause.cause is ExtractionException -> getMessageStringId(throwable, action)
134- throwable.type == ExoPlaybackException .TYPE_SOURCE -> R .string.player_stream_failure
135- throwable.type == ExoPlaybackException .TYPE_UNEXPECTED -> R .string.player_recoverable_failure
136- else -> R .string.player_unrecoverable_failure
137- }
138- }
139- throwable is FailedMediaSource .FailedMediaSourceException -> getMessageStringId(throwable.cause, action)
140- throwable is PlaybackResolver .ResolverException -> R .string.player_stream_failure
141-
142- // user actions (in case the exception is unrecognizable)
145+ // user actions (in case the exception is null or unrecognizable)
143146 action == UserAction .UI_ERROR -> R .string.app_ui_crash
144147 action == UserAction .REQUESTED_COMMENTS -> R .string.error_unable_to_load_comments
145148 action == UserAction .SUBSCRIPTION_CHANGE -> R .string.subscription_change_failed
0 commit comments