Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
        public void AddTwitterException(ITwitterException twitterException)
        {
            lock (_lockExceptionInfos)
            {
                _exceptionInfos.Add(twitterException);
            }

            this.Raise(WebExceptionReceived, twitterException);
        }
        public void AddTwitterException(ITwitterException twitterException)
        {
            lock (_lockExceptionInfos)
            {
                _exceptionInfos.Add(twitterException);
            }

            this.Raise(WebExceptionReceived, twitterException);
        }
Exemplo n.º 5
0
 public static void AddTwitterException(ITwitterException twitterException)
 {
     CurrentThreadExceptionHandler.AddTwitterException(twitterException);
 }
Exemplo n.º 6
0
 public void RaiseOnTwitterException(ITwitterException exception)
 {
     this.Raise(OnTwitterException, exception);
 }
Exemplo n.º 7
0
 protected void RaiseOnTwitterException(object sender, ITwitterException exception)
 {
     OnTwitterException?.Invoke(sender, exception);
 }
Exemplo n.º 8
0
 private void HandleTwitterException(object sender, ITwitterException e)
 {
     LogUtil.LogError($"({e.CreationDate}) {e.Content}", nameof(TwitterBot));
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 public static void AddTwitterException(ITwitterException twitterException)
 {
     CurrentThreadExceptionHandler.AddTwitterException(twitterException);
 }