1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-15 06:15:47 +02:00

Add exception type that adds (potentially sensitive) details to error log

This commit is contained in:
chylex 2018-06-30 13:20:25 +02:00
parent 38b01deec1
commit 738557b3a2

View File

@ -46,8 +46,9 @@ public bool Log(string data){
public void HandleException(string caption, string message, bool canIgnore, Exception e){
bool loggedSuccessfully = Log(e.ToString());
FormMessage form = new FormMessage(caption, message+"\nError: "+e.Message, canIgnore ? MessageBoxIcon.Warning : MessageBoxIcon.Error);
string exceptionText = e is ExpandedLogException ? e.Message+"\n\nDetails with potentially sensitive information are in the Error Log." : e.Message;
FormMessage form = new FormMessage(caption, message+"\nError: "+exceptionText, canIgnore ? MessageBoxIcon.Warning : MessageBoxIcon.Error);
Button btnExit = form.AddButton(FormMessage.Exit);
Button btnIgnore = form.AddButton(FormMessage.Ignore, DialogResult.Ignore, ControlType.Cancel);
@ -95,5 +96,15 @@ public static void HandleEarlyFailure(string caption, string message){
Environment.FailFast(message, new Exception(message));
}
}
public sealed class ExpandedLogException : Exception{
private readonly string details;
public ExpandedLogException(Exception source, string details) : base(source.Message, source){
this.details = details;
}
public override string ToString() => base.ToString()+"\r\n"+details;
}
}
}