Skip to content

Add more specific error messages and deduplicate their handling#12477

Closed
Stypox wants to merge 3 commits intoTeamNewPipe:release-0.28.0from
Stypox:better-error-messages
Closed

Add more specific error messages and deduplicate their handling#12477
Stypox wants to merge 3 commits intoTeamNewPipe:release-0.28.0from
Stypox:better-error-messages

Conversation

@Stypox
Copy link
Member

@Stypox Stypox commented Jul 28, 2025

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

This PR deduplicates the decision of which error message to show for which throwable (it was done in 3 different places previously). It also adds some nice new error messages for specific errors, so users understand better what is going on (and maybe complain less when YouTube breaks something ;-) ).

  • In RouterActivity, a toast is shown like before if the error is not something that usually needs to be reported, as to not distract the user with a notification.
  • Make error snackbar display the actual error that has occurred, instead of showing "Sorry, something went wrong" every time. For example, "Could not parse website" is much more explanatory as the snackbar description when some item in a list can not be extracted (this is already shown in the error panel).
  • All subclasses of ContentNotAvailableException now have nice specific error messages, and in particular this PR adds UnsupportedContentInCountryException (from @AudricV's new Youtube trending implementation) and YoutubeSignInConfirmNotBotException ( [YouTube] Add custom error for "Sign in to confirm ..." NewPipeExtractor#1352). The latter in particular will hopefully help reduce the amount of duplicate comments in [YouTube] "Sign in to confirm..."/"Watch on the latest version..." #11139.
  • Various player-related exceptions are now inspected to extract the original cause and show that to the user instead of always saying "Could not play this stream". In particular, 403 errors are detected and a custom error message is shown for them: "HTTP error 403 occurred while playing, likely caused by an IP ban or streaming URL deobfuscation issues" (this message was inspired by FreeTube's). This should also help reduce the amount of duplicates we get related to 403 errors.

Relies on the following changes

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Debug APK from CI: app(1).zip

Due diligence

@github-actions github-actions bot added the size/medium PRs with less than 250 changed lines label Jul 28, 2025
@Stypox Stypox force-pushed the better-error-messages branch from 9f727b0 to 13d1917 Compare July 28, 2025 22:24
Copy link
Member

@litetex litetex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stypox on fire today 🔥
Thank you for the PR!

I did some testing with some common exceptions but it's hard to test all possible combinations.

However Code LGTM

// If there’s already a git hash, just add more of it to the end (or remove a letter)
// to cause jitpack to regenerate the artifact.
implementation 'com.github.TeamNewPipe:NewPipeExtractor:7adbc48a0aa872c016b8ec089e278d5e12772054'
implementation 'com.github.Stypox:NewPipeExtractor:1c04bd88c3f1e6b1e0c912814035745e61bb9aba'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed before merging

@StringRes
private fun getMessageStringId(
fun getMessageStringId(
throwable: Throwable?,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a stupid question but why are we catching Throwables in the first place and not Exceptions?

If we encounter an Error that usually means a critical error that must result in a VM crash, like OutOfMemoryError, etc

Copy link
Member Author

@Stypox Stypox Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example when the app crashes and ACRA catches the throwable and starts the error report screen, that throwable could be anything. In other places... well yeah maybe we don't need to catch Throwables, but just to be sure sometimes we do. E.g. StackOverflowError is not an Exception, but if we have a recursive stack overflow somewhere (e.g. the extractor) we still want to handle it nicely instead of crashing the app.

@Stypox Stypox added this to v0.28.x Jul 30, 2025
@github-project-automation github-project-automation bot moved this to Todo in v0.28.x Jul 30, 2025
@Stypox Stypox moved this from Todo to In Progress in v0.28.x Jul 30, 2025
@Stypox Stypox mentioned this pull request Jul 30, 2025
11 tasks
@Stypox Stypox deleted the branch TeamNewPipe:release-0.28.0 July 31, 2025 21:51
@Stypox Stypox closed this Jul 31, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in v0.28.x Jul 31, 2025
@litetex
Copy link
Member

litetex commented Aug 1, 2025

Was closing this intentional?

@TobiGr
Copy link
Contributor

TobiGr commented Aug 1, 2025

This pointed to the release branch which was deleted and thus the PR closed automatically. This should be reopened targeting dev

@litetex
Copy link
Member

litetex commented Aug 7, 2025

@Stypox
Reminder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/medium PRs with less than 250 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants