The first exception of type "System.Net.WebException" occurred in System.dll

I use TweetSharp to find subscribers for the user.

Here is the code:

public static void FindFollowersForUser(TwitterUserModel twitterUser)
{
    try
    {
        var followers = service.ListFollowersOf(twitterUser.TwitterName, -1);
        if (followers == null) return;
        while (followers.NextCursor != null)
        {
            var foundFollowers = service.ListFollowersOf(twitterUser.TwitterName, (long)followers.NextCursor);
            if (foundFollowers == null) continue;

            Debug.WriteLine("Followers found for: " + twitterUser.TwitterName);
            foreach (var follower in foundFollowers)
            {
                twitterUser.Followers.Add(follower.ScreenName);
            }
        }
    }
    catch (WebException e)
    {
        throw e;
    }
}

I tried wrapping the code in try / catch to catch a WebException error and catching an InnerException, but catch is never thrown, even though the error message is displayed in the output window ( View -> Output) in Visual Studio.

How can I see the internal exception of this error? This is the first time I have seen a debugger not launch a catch when an exception is thrown.

+3
source share
2 answers

, " ", , Debug? , . . TweetSharp - , catch

, . - ( "" ), .

+12

- , . rethrow,

catch (WebException e) { throw e; }

stacktrace.

catch (WebException e) { throw; }
+1

All Articles