question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception escapes try/catch

See original GitHub issue

Hey, when I try to download a restricted video in my country just like this: “https://www.youtube.com/watch?v=iN8PKcNGcuI” I get an exception saying “YoutubeExplode.Exceptions.VideoUnavailableException” and the program stops working. even that I wrote it in (try-catch) how to fix it? Here is a part of my code(it stops at the last line)

            try
            {
                //string Path = Directory.GetCurrentDirectory();
                //GrantAccess(Path);
                var url = GetYoutubeUrl();
                if (url != "")
                {
                    var id = YoutubeClient.ParseVideoId(url); // "bnsUkE8i0tU"
                    var client = new YoutubeClient();
                    var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
SlowLogicBoycommented, May 23, 2018

how does your catch look like? I can’t reproduce this at all. This is possible unless you rethrow exception in catch, or you have try/finally without catch.

I can reproduce this with:

#! "netcoreapp2.0"
#r "nuget: YoutubeExplode, *"

using YoutubeExplode;

try
{
    var url = "https://www.youtube.com/watch?v=iN8PKcNGcuI";
    if (url != "")
    {
        var id = YoutubeClient.ParseVideoId(url); // "bnsUkE8i0tU"
        var client = new YoutubeClient();
        var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);
    }
}finally{
    
}

and

#! "netcoreapp2.0"
#r "nuget: YoutubeExplode, *"

using YoutubeExplode;

try
{
    var url = "https://www.youtube.com/watch?v=iN8PKcNGcuI";
    if (url != "")
    {
        var id = YoutubeClient.ParseVideoId(url); // "bnsUkE8i0tU"
        var client = new YoutubeClient();
        var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);
    }
}catch{
    throw;
}

but with:

#! "netcoreapp2.0"
#r "nuget: YoutubeExplode, *"

using YoutubeExplode;

try
{
    var url = "https://www.youtube.com/watch?v=iN8PKcNGcuI";
    if (url != "")
    {
        var id = YoutubeClient.ParseVideoId(url); // "bnsUkE8i0tU"
        var client = new YoutubeClient();
        var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);
    }
}catch{
    Console.WriteLine("Catch");
}

I get output catch and there are no unhandled exceptions thrown.

1reaction
remiX-commented, May 22, 2018

I’ve also had a few of these which kinda sucks… Can’t find a way around it. As far as I know, you can’t download videos that are blocked 😕 A VPN could possibly work but I haven’t been bothered enough to try

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible for an exception to escape a try catch block?
catch (Exception ex) and just catch have become same. and no, it's not possible to escape from try/catch except StackoverFlowException etc.
Read more >
try...catch - JavaScript - MDN Web Docs - Mozilla
When an exception is thrown in the try block, exceptionVar (i.e., the e in catch (e) ) holds the exception value. You can...
Read more >
Escaping the Exception Trap (Java in General forum at ...
I have a situation in a java program where exclude a statement from the exception trap. Below is the example that will make...
Read more >
Exception propagation: When should I catch exceptions?
If a method can't handle the exception, and doesn't need to do anything else when an exception is thrown then there is no...
Read more >
Exceptions and debugging - Advanced R. - Hadley Wickham
tryCatch () is a general tool for handling conditions: in addition to errors, you can take different actions for warnings, messages, and interrupts....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found