diff --git a/Reactor.Greenhouse/Program.cs b/Reactor.Greenhouse/Program.cs index 744d047..9c2f625 100644 --- a/Reactor.Greenhouse/Program.cs +++ b/Reactor.Greenhouse/Program.cs @@ -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 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) diff --git a/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs b/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs index b552ab7..296ea93 100644 --- a/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs +++ b/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs @@ -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) + { + } + } +} \ No newline at end of file diff --git a/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs b/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs index 543e323..76de562 100644 --- a/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs +++ b/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs @@ -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) + { + + } + } }