Skip to content

Commit

Permalink
Debug stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew committed Jan 15, 2016
1 parent ecc2ee0 commit 4df81ae
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
4 changes: 4 additions & 0 deletions SteamCleaner/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region

using System.Diagnostics;
using System.Windows;
using SteamCleaner.Utilities;

Expand All @@ -14,6 +15,9 @@ public partial class App : Application
{
private void AppStartup(object sender, StartupEventArgs args)
{
if (!Debugger.IsAttached)
ExceptionHandler.AddGlobalHandlers();

var mainWindow = new MainWindow
{
DataContext = new MainWindowViewModel()
Expand Down
1 change: 1 addition & 0 deletions SteamCleaner/SteamCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Clients\Gog.cs" />
<Compile Include="Clients\Steam.cs" />
<Compile Include="Utilities\ExceptionHandler.cs" />
<Compile Include="Utilities\StringUtilities.cs" />
<Compile Include="Utilities\CleanerUtilities.cs" />
<Compile Include="Utilities\Tools.cs" />
Expand Down
2 changes: 1 addition & 1 deletion SteamCleaner/Utilities/CleanerUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static List<string> DetectRenPyRedistributables(string sDir)
files.AddRange(DetectRenPyRedistributables(d));
foreach (var filter in filters.Where(filter => d.ToLower().Contains(filter)))
{
files.AddRange(from f in Directory.GetFiles(d) select f);
files.AddRange(Directory.GetFiles(d).Select(f => f));
}
}
return files;
Expand Down
39 changes: 39 additions & 0 deletions SteamCleaner/Utilities/ExceptionHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace SteamCleaner.Utilities
{
public static class ExceptionHandler
{
private static readonly string LogsPath = Path.Combine("", "Logs");

public static void AddGlobalHandlers()
{
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
try
{
if (!Directory.Exists(LogsPath))
Directory.CreateDirectory(LogsPath);

var filePath = Path.Combine(LogsPath,
$"UnhandledException_{DateTime.Now.ToShortDateString().Replace("/", "-")}.json");

File.AppendAllText(filePath,
JsonConvert.SerializeObject(args.ExceptionObject, Formatting.Indented) + "\r\n\r\n");

Console.WriteLine("An Unhandled Exception was Caught and Logged to:\r\n{0}", filePath);
}
catch
{
// ignored
}
};
}
}
}
2 changes: 1 addition & 1 deletion version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<steamcleaner>
<version>1.7</version>
<version>1.8</version>
<url>https://github.com/Codeusa/SteamCleaner/releases/latest</url>
</steamcleaner>

0 comments on commit 4df81ae

Please sign in to comment.