Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #539 from cwhelchel/fix/i404

Bug-fix patch for #404
  • Loading branch information...
commit 5b03ad5ab20016659ff77f93a068e0ba5d5ff960 2 parents 9475859 + cb37020
@Jessecar96 authored
Showing with 19 additions and 6 deletions.
  1. +19 −6 SteamTrade/Trade.cs
View
25 SteamTrade/Trade.cs
@@ -438,21 +438,34 @@ public bool AcceptTrade ()
/// <returns>The result of the function if it succeeded, or default(T) (null/false/0) otherwise</returns>
private T RetryWebRequest<T>(Func<T> webEvent)
{
- for(int i = 0; i < WEB_REQUEST_MAX_RETRIES; i++)
+ for (int i = 0; i < WEB_REQUEST_MAX_RETRIES; i++)
{
//Don't make any more requests if the trade has ended!
- if(HasTradeCompletedOk || OtherUserCancelled)
+ if (HasTradeCompletedOk || OtherUserCancelled)
return default(T);
- T result = webEvent();
- if(!EqualityComparer<T>.Default.Equals(result, default(T)))
- return result;
- if(i != WEB_REQUEST_MAX_RETRIES)
+ try
+ {
+ T result = webEvent();
+
+ // if the web request returned some error.
+ if (!EqualityComparer<T>.Default.Equals(result, default(T)))
+ return result;
+ }
+ catch (Exception ex)
+ {
+ // TODO: log to SteamBot.Log but... see issue #394
+ // realistically we should not throw anymore
+ Console.WriteLine(ex);
+ }
+
+ if (i != WEB_REQUEST_MAX_RETRIES)
{
//This will cause the bot to stop responding while we wait between web requests. ...Is this really what we want?
Thread.Sleep(WEB_REQUEST_TIME_BETWEEN_RETRIES_MS);
}
}
+
return default(T);
}
Please sign in to comment.
Something went wrong with that request. Please try again.