private static async Task Main()

in CommandLine/XblConnectedStorage/Program.cs [20:83]


        private static async Task<int> Main(string[] args)
        {
            Options options = null;

            try
            {
                // Only assign the option and verb here, as the commandlineParser doesn't support async callback yet.
                ParserResult<Options> result = Parser.Default.ParseArguments<Options>(args)
                    .WithParsed(parsedOptions => 
                    {
                        options = parsedOptions;
                    });

                if (options == null)
                {
                    Console.Error.WriteLine("Parsing parameters error.");
                    return -1;
                }

                if (options.GamerTag.Contains("#"))
                {
                    Console.Error.WriteLine("Modern gamertags are not supported. Please use a legacy gamertag.");
                    return -1;
                }

                DevAccount account = ToolAuthentication.LoadLastSignedInUser();
                if (account == null)
                {
                    Console.Error.WriteLine("Didn't found dev sign in info, please use \"XblDevAccount.exe signin\" to initiate.");
                    return -1;
                }

                Console.WriteLine($"Using Dev account {account.Name} from {account.AccountSource}");

                return await OnDownload(options);
            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine($"Error: XblConnectedStorage failed.");

                if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Unauthorized)))
                {
                    Console.WriteLine(
                        $"Unable to authorize the account with XboxLive service with scid : {options?.ServiceConfigurationId} and sandbox : {options?.Sandbox}, please contact your administrator.");
                }
                else if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Forbidden)))
                {
                    Console.WriteLine(
                        "Your account doesn't have access to perform the operation, please contact your administrator.");
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }

                return -1;
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error: unexpected error found.");
                Console.Error.WriteLine(ex.Message);
                return -1;
            }
        }