From 7a4666aa155b4276038596bb6788e37b3d8f185f Mon Sep 17 00:00:00 2001 From: Tichau Date: Tue, 2 Feb 2016 08:51:36 +0100 Subject: [PATCH] Better error handling --- Application/FileConverter/Application.xaml.cs | 36 +++++++------------ .../ConversionJobs/ConversionJob.cs | 13 +++++-- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Application/FileConverter/Application.xaml.cs b/Application/FileConverter/Application.xaml.cs index a74c68d..9aa6505 100644 --- a/Application/FileConverter/Application.xaml.cs +++ b/Application/FileConverter/Application.xaml.cs @@ -165,29 +165,12 @@ namespace FileConverter string[] args = Environment.GetCommandLineArgs(); #if (DEBUG) - if (args.Length <= 1) { - //System.Array.Resize(ref args, 8); - //args[1] = "--conversion-preset"; - //args[2] = "To Ogg"; - //args[3] = "--verbose"; - - //args[4] = @"D:\Test\TrailerV2 compressed.mkv"; - //args[4] = @"D:\Test\image.png"; - //args[4] = @"E:\Track01.cda"; - //args[4] = @"D:\Test\Track01.mp3"; - //args[5] = @"D:\Test\Track02.mp3"; - //args[6] = @"D:\Test\Track03.mp3"; - //args[7] = @"D:\Test\Track04.mp3"; - - System.Array.Resize(ref args, 2); - args[1] = "--settings"; - - //System.Array.Resize(ref args, 5); - //args[1] = "--conversion-preset"; - //args[2] = "To Jpg"; - //args[3] = "--verbose"; - //args[4] = @"D:\Test\Test avec accents héhé\imagé.png"; + System.Array.Resize(ref args, 5); + args[1] = "--conversion-preset"; + args[2] = "To Ico"; + args[3] = "--verbose"; + args[4] = @"D:\Test\images\ApplicationIcon.svg"; } #endif @@ -426,7 +409,14 @@ namespace FileConverter return; } - conversionJob.StartConvertion(); + try + { + conversionJob.StartConvertion(); + } + catch (Exception) + { + throw; + } if (conversionJob.State == ConversionJob.ConversionState.Done && !System.IO.File.Exists(conversionJob.OutputFilePath)) { diff --git a/Application/FileConverter/ConversionJobs/ConversionJob.cs b/Application/FileConverter/ConversionJobs/ConversionJob.cs index 7c73f9b..6f24b55 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob.cs @@ -252,8 +252,15 @@ namespace FileConverter.ConversionJobs Debug.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath); this.State = ConversionState.InProgress; - - this.Convert(); + + try + { + this.Convert(); + } + catch (Exception exception) + { + this.ConversionFailed(exception.Message); + } if (this.State == ConversionState.Failed) { @@ -323,6 +330,8 @@ namespace FileConverter.ConversionJobs protected void ConversionFailed(string exitingMessage) { + Debug.Log("Fail: {0}", exitingMessage); + if (this.State == ConversionState.Failed) { // Already failed, don't override informations.