Esempio n. 1
0
        public static void ShowDirectoryCreationFailError(Exception exception, string folderPath)
        {
            bool flag = false;

            if (exception is UnauthorizedAccessException)
            {
                flag = true;
            }
            if (exception is FileNotFoundException)
            {
                flag = true;
            }
            if (exception is DirectoryNotFoundException)
            {
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            StringBuilder text = new StringBuilder();

            text.AppendLine("Failed to create the folder: \"" + folderPath.Replace("/", "\\") + "\"!");
            List <string> suggestions = new List <string>();

            suggestions.Add("If you are using an Anti-virus, please make sure it does not block Terraria in any way.");
            suggestions.Add("Try making sure your `Documents/My Games/Terraria` folder is not set to 'read-only'.");
            suggestions.Add("Try to verify/repair the game installation.");
            if (folderPath.ToLower().Contains("onedrive"))
            {
                suggestions.Add("Try updating OneDrive.");
            }
            text.AppendLine();
            text.AppendLine("Suggestions:");
            FancyErrorPrinter.AppendSuggestions(text, suggestions);
            text.AppendLine();
            FancyErrorPrinter.IncludeOriginalMessage(text, exception);
            FancyErrorPrinter.ShowTheBox(text.ToString());
            Console.WriteLine((object)exception);
        }
Esempio n. 2
0
        public static void ShowFailedToLoadAssetError(Exception exception, string filePath)
        {
            bool flag = false;

            if (exception is UnauthorizedAccessException)
            {
                flag = true;
            }
            if (exception is FileNotFoundException)
            {
                flag = true;
            }
            if (exception is DirectoryNotFoundException)
            {
                flag = true;
            }
            if (exception is AssetLoadException)
            {
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            StringBuilder text = new StringBuilder();

            text.AppendLine("Failed to load asset: \"" + filePath.Replace("/", "\\") + "\"!");
            List <string> suggestions = new List <string>();

            suggestions.Add("Try to verify/repair the game installation, the asset may be missing.");
            suggestions.Add("If you are using an Anti-virus, please make sure it does not block Terraria in any way.");
            text.AppendLine();
            text.AppendLine("Suggestions:");
            FancyErrorPrinter.AppendSuggestions(text, suggestions);
            text.AppendLine();
            FancyErrorPrinter.IncludeOriginalMessage(text, exception);
            FancyErrorPrinter.ShowTheBox(text.ToString());
            Console.WriteLine(text.ToString());
        }