andruzzzhka / BeatSaverDownloader

Mod for Beat Saber to download songs from BeatSaver.com in-game
MIT License
71 stars 41 forks source link

VotingUI's error handling is never hit resulting in a "generic error" being reported #25

Closed piercy closed 5 years ago

piercy commented 5 years ago

Hey, so i was getting an error with voting for songs, it was just reporting "Generic/Unknown HTTP Error" in the logs and on screen. So i took a look in the code and in VotingUI.cs line 155 you have an if statement that checks for network or http errors. The problem is, if this is true, it doesnt then go into the else, and then it doesnt display the nice errors you have in the switch statement at line 169.

For example, my error was that i was using a read only token. So beatsaver returned a 403 but because of the if statement on line 155, it never hits the code at line 198. Thus i get a generic error rather than "read-only token" error.

You could potentially use the below code to get the error from the content, else i think changing the if statement so it only handles network error and not http errors would work. Either way currently nothing but a 200 response will hit the switch at line 169.

JSONNode node = JSON.Parse(voteWWW.downloadHandler.text);
actualError = "Voting Error" + node["message"];

Hope this makes sense

andruzzzhka commented 5 years ago

Thanks for the report!

andruzzzhka commented 5 years ago

Done!