iBicha / UnityYoutubePlayer

Play YouTube videos in Unity
The Unlicense
336 stars 63 forks source link

Get Error when PrepareVideoAsync can't load. #45

Closed RayosElDev closed 3 years ago

RayosElDev commented 3 years ago

Hello, If I have this code

 public async void Prepare()
        {
            print("Loading...");
            try
            {
                await youtubePlayer.PrepareVideoAsync();
                print("Video Loaed");
            }
            catch
            {
                print("Error to Load");
            }

        }

In my Cath i print ok error appear. But How can I control the error? Like, for internet conection, for no find URL, or for other kind of error.

Thankks

iBicha commented 3 years ago

That's a good question, thanks for the issue. Currently when the request fails, it throws a generic Exception class. It needs to be a more specific exception type to be handled the way you described it. I will work on adding this when I get some time (unless someone else puts up a pull request for this)

RayosElDev commented 3 years ago

Thanks, sounds really good. Because I show your package in my school and can't show any video...maybe for permissions of the security in school..but bad luck hahah

iBicha commented 3 years ago

You can still get information on why the error happened

            catch(Exception ex)
            {
                Debug.LogException(ex);
            }
RayosElDev commented 3 years ago

Oh god, system exception works! oh, im sucker. Really thanks! its works enough I think,.

You are the best! And thanks for answers so quick :D

iBicha commented 3 years ago

It would be a good improvement to provide different exception types for different errors. I will close this issue since this is resolved though.