private static string GetExceptionInfos(ITwitterException twitterException) { var messages = string.Join("\n", twitterException.TwitterExceptionInfos.Select(x => x.Message)); var status = $"{twitterException.TwitterDescription}\n {messages}"; return(status); }
public async Task ShouldProperlyHandleExceptionsAsync() { if (!EndToEndTestConfig.ShouldRunEndToEndTests) { return; } ITwitterException globalException = null; ITwitterException clientException = null; TweetinviEvents.OnTwitterException += (sender, exception) => { globalException = exception; }; var invalidCredentials = new TwitterCredentials("a", "b", "c", "d"); var client = new TwitterClient(invalidCredentials); TweetinviEvents.SubscribeToClientEvents(client); client.Events.OnTwitterException += (sender, exception) => { clientException = exception; }; try { await client.Users.GetAuthenticatedUserAsync(); } catch (TwitterException e) { Assert.Equal(401, e.StatusCode); Assert.Equal(globalException, e); Assert.Equal(clientException, e); return; } throw new Exception("Should have thrown a TwitterException"); }
public void AddTwitterException(ITwitterException twitterException) { lock (_lockExceptionInfos) { _exceptionInfos.Add(twitterException); } this.Raise(WebExceptionReceived, twitterException); }
public static void AddTwitterException(ITwitterException twitterException) { CurrentThreadExceptionHandler.AddTwitterException(twitterException); }
public void RaiseOnTwitterException(ITwitterException exception) { this.Raise(OnTwitterException, exception); }
protected void RaiseOnTwitterException(object sender, ITwitterException exception) { OnTwitterException?.Invoke(sender, exception); }
private void HandleTwitterException(object sender, ITwitterException e) { LogUtil.LogError($"({e.CreationDate}) {e.Content}", nameof(TwitterBot)); }
private static string GetExceptionInfos(ITwitterException twitterException) { var messages = string.Join("\n", twitterException.TwitterExceptionInfos.Select(x => x.Message)); var status = $"{twitterException.TwitterDescription}\n {messages}"; return status; }