1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-09 23:34:06 +02:00

Move unhandled exception handler from Program to Reporter class

This commit is contained in:
chylex 2016-11-19 03:11:37 +01:00
parent 45e6ec8b0f
commit 3f0028913d
2 changed files with 11 additions and 8 deletions

View File

@ -60,14 +60,7 @@ private static void Main(){
}
Reporter = new Reporter(LogFilePath);
AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
Exception ex = args.ExceptionObject as Exception;
if (ex != null){
Reporter.HandleException(BrandName+" Has Failed :(", "An unhandled exception has occurred.", false, ex);
}
};
Reporter.SetupUnhandledExceptionHandler(BrandName+" Has Failed :(");
if (Args.HasFlag("-restart")){
for(int attempt = 0; attempt < 21; attempt++){

View File

@ -15,6 +15,16 @@ public Reporter(string logFile){
this.logFile = logFile;
}
public void SetupUnhandledExceptionHandler(string caption){
AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
Exception ex = args.ExceptionObject as Exception;
if (ex != null){
HandleException(caption, "An unhandled exception has occurred.", false, ex);
}
};
}
public bool Log(string data){
StringBuilder build = new StringBuilder();