Added error handling to the Steam connection.
This commit is contained in:
3 files changed
+46
-5
No files matched your search
@@ -11,6 +11,7 @@ using Mono.Cecil;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Reactor.Greenhouse.Setup;
|
||||
using Reactor.Greenhouse.Setup.Provider;
|
||||
using Reactor.OxygenFilter;
|
||||
|
||||
namespace Reactor.Greenhouse
|
||||
@@ -30,10 +31,20 @@ namespace Reactor.Greenhouse
|
||||
return rootCommand.InvokeAsync(args);
|
||||
}
|
||||
|
||||
public static async Task GenerateAsync(bool steam, bool itch)
|
||||
public static async Task<int> GenerateAsync(bool steam, bool itch)
|
||||
{
|
||||
var gameManager = new GameManager();
|
||||
await gameManager.SetupAsync(steam, itch);
|
||||
|
||||
try
|
||||
{
|
||||
await gameManager.SetupAsync(steam, itch);
|
||||
}
|
||||
catch (ProviderConnectionException e)
|
||||
{
|
||||
Console.WriteLine($"Error downloading version : {e.Message}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||
{
|
||||
@@ -55,6 +66,8 @@ namespace Reactor.Greenhouse
|
||||
{
|
||||
await GenerateAsync(gameManager.Itch, old);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static async Task GenerateAsync(Game game, ModuleDefinition old)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Reactor.Greenhouse.Setup.Provider
|
||||
@@ -10,4 +11,11 @@ namespace Reactor.Greenhouse.Setup.Provider
|
||||
public abstract Task DownloadAsync();
|
||||
public abstract bool IsUpdateNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ProviderConnectionException : Exception
|
||||
{
|
||||
protected ProviderConnectionException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,15 @@ namespace Reactor.Greenhouse.Setup.Provider
|
||||
if (environmentVariable != null)
|
||||
{
|
||||
var split = environmentVariable.Split(":");
|
||||
ContentDownloader.InitializeSteam3(split[0], split[1]);
|
||||
if(!ContentDownloader.InitializeSteam3(split[0], split[1]))
|
||||
{
|
||||
throw new SteamProviderConnectionException("Wrong password");
|
||||
}
|
||||
|
||||
if (ContentDownloader.steam3 == null || !ContentDownloader.steam3.bConnected)
|
||||
{
|
||||
throw new SteamProviderConnectionException("Unable to initialize Steam");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,7 +93,11 @@ namespace Reactor.Greenhouse.Setup.Provider
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
ContentDownloader.InitializeSteam3(username, password);
|
||||
if (!ContentDownloader.InitializeSteam3(username, password))
|
||||
{
|
||||
throw new SteamProviderConnectionException("Unable to initialize Steam");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ContentDownloader.Config.UsingFileList = true;
|
||||
@@ -106,4 +118,12 @@ namespace Reactor.Greenhouse.Setup.Provider
|
||||
return ContentDownloader.DownloadAppAsync(AppId, DepotId, IsPreObfuscation ? PreObfuscationManifest : ContentDownloader.INVALID_MANIFEST_ID);
|
||||
}
|
||||
}
|
||||
|
||||
public class SteamProviderConnectionException : ProviderConnectionException
|
||||
{
|
||||
public SteamProviderConnectionException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user