Skip to content

Commit c9df2d8

Browse files
author
babelshift
committed
Handle HTTP 404 exception for UGC File Details lookup.
1 parent 08db082 commit c9df2d8

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

SteamWebAPI2/Interfaces/SteamRemoteStorage.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Diagnostics;
6+
using System.Net.Http;
67
using System.Threading.Tasks;
78

89
namespace SteamWebAPI2.Interfaces
@@ -18,7 +19,7 @@ public async Task<UGCFileDetails> GetUGCFileDetailsAsync(long ugcId, int appId,
1819
{
1920
Debug.Assert(appId > 0);
2021

21-
if(ugcId <= 0)
22+
if (ugcId <= 0)
2223
{
2324
return null;
2425
}
@@ -29,8 +30,15 @@ public async Task<UGCFileDetails> GetUGCFileDetailsAsync(long ugcId, int appId,
2930
AddToParametersIfHasValue(appId, "appid", parameters);
3031
AddToParametersIfHasValue(steamId, "steamid", parameters);
3132

32-
var ugcFileDetails = await CallMethodAsync<UGCFileDetailsResultContainer>("GetUGCFileDetails", 1, parameters);
33-
return ugcFileDetails.Result;
33+
try
34+
{
35+
var ugcFileDetails = await CallMethodAsync<UGCFileDetailsResultContainer>("GetUGCFileDetails", 1, parameters);
36+
return ugcFileDetails.Result;
37+
}
38+
catch (HttpRequestException)
39+
{
40+
return null;
41+
}
3442
}
3543
}
3644
}

SteamWebAPI2/SteamWebRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public string BuildRequestCommand(string interfaceName, string methodName, int m
117117
string commandUrl = String.Format("{0}/{1}/{2}/v{3}/", steamWebApiBaseUrl, interfaceName, methodName, methodVersion);
118118

119119
// if we have parameters, join them together with & delimiter and append them to the command URL
120-
if(parameters != null && parameters.Count > 0)
120+
if (parameters != null && parameters.Count > 0)
121121
{
122122
string parameterString = String.Join("&", parameters);
123123
commandUrl += String.Format("?{0}", parameterString);

0 commit comments

Comments
 (0)