Skip to content

Commit

Permalink
added exception sanitizing
Browse files Browse the repository at this point in the history
  • Loading branch information
GHXX committed Jun 27, 2021
1 parent 1adce62 commit add7547
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DataInterfaceConsole/Actions/Settings/SettingsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void Tick()
}
catch (Exception ex)
{
Console.WriteLine($"Error while ticking settings handler:\n{ex}");
Console.WriteLine($"Error while ticking settings handler:\n{ex.ToSanitizedString()}");
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions DataInterfaceConsole/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Text.RegularExpressions;

namespace DataInterfaceConsole
{
internal static class Extensions
{
public static string ToSanitizedString(this Exception e) => Regex.Replace(e.ToString(), @"([A-z]:[\\\/]Users[\\\/])(.*?)([\\\/])", "$1USERNAME$3");
}
}
4 changes: 2 additions & 2 deletions DataInterfaceConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void Run()
}
catch (DataInterfaceClosedException ex)
{
Util.WriteColored($"Execution of the current action '{a.Name}' was aborted because the game closed or crashed: \n{ex}", ConsoleColor.Red);
Util.WriteColored($"Execution of the current action '{a.Name}' was aborted because the game closed or crashed: \n{ex.ToSanitizedString()}", ConsoleColor.Red);
ConsoleNonBlocking.ClearInputLines();
}
break;
Expand All @@ -79,7 +79,7 @@ private void Run()
}
catch (DataInterfaceClosedException ex)
{
Util.WriteColored($"Execution of the current action selection was aborted because the game closed or crashed: \n{ex}", ConsoleColor.Red);
Util.WriteColored($"Execution of the current action selection was aborted because the game closed or crashed: \n{ex.ToSanitizedString()}", ConsoleColor.Red);
ConsoleNonBlocking.ClearInputLines();
}
}
Expand Down

0 comments on commit add7547

Please sign in to comment.