diff options
author | sr55 <[email protected]> | 2011-09-26 20:57:50 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-09-26 20:57:50 +0000 |
commit | 93c56509e64cf7ac43036260037966433a65f553 (patch) | |
tree | b0ab935bd127761c09205adfd812aef1b8511f98 /win/CS | |
parent | 4c69e1c1f7afd0be88d70caedd25290422d09775 (diff) |
WinGui: Some refactoring of code that throws exceptions.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4256 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/Functions/Main.cs | 28 | ||||
-rw-r--r-- | win/CS/frmActivityWindow.cs | 5 | ||||
-rw-r--r-- | win/CS/frmMain.cs | 5 | ||||
-rw-r--r-- | win/CS/frmPreview.cs | 4 |
4 files changed, 16 insertions, 26 deletions
diff --git a/win/CS/Functions/Main.cs b/win/CS/Functions/Main.cs index f80233066..8d88871c2 100644 --- a/win/CS/Functions/Main.cs +++ b/win/CS/Functions/Main.cs @@ -16,6 +16,7 @@ namespace Handbrake.Functions using System.Xml.Serialization;
using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Extensions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
@@ -135,7 +136,7 @@ namespace Handbrake.Functions /// <param name="mainWindow">Main Window</param>
/// <param name="filePathName">Path to save the csv file</param>
/// <returns>True if successful </returns>
- public static bool SaveChapterMarkersToCsv(frmMain mainWindow, string filePathName)
+ public static void SaveChapterMarkersToCsv(frmMain mainWindow, string filePathName)
{
try
{
@@ -152,12 +153,10 @@ namespace Handbrake.Functions file.Write(csv);
file.Close();
file.Dispose();
- return true;
}
catch (Exception exc)
{
- ShowExceptiowWindow("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode", exc.ToString());
- return false;
+ throw new GeneralApplicationException("Unable to save Chapter Makrers file! ", "Chapter marker names will NOT be saved in your encode.", exc);
}
}
@@ -371,7 +370,10 @@ namespace Handbrake.Functions UserSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeVersion, string.Empty);
UserSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeExeHash, string.Empty);
- ShowExceptiowWindow("Unable to retrieve version information from the CLI.", e.ToString());
+ ExceptionWindow window = new ExceptionWindow();
+ window.Setup("Unable to Initialise HandBrake \nThis error is unrecoverable. Maybe try restarting.", e.ToString());
+ window.ShowDialog();
+
Application.Exit();
}
}
@@ -466,22 +468,6 @@ namespace Handbrake.Functions }
/// <summary>
- /// Show the Exception Window
- /// </summary>
- /// <param name="shortError">
- /// The short error.
- /// </param>
- /// <param name="longError">
- /// The long error.
- /// </param>
- public static void ShowExceptiowWindow(string shortError, string longError)
- {
- ExceptionWindow window = new ExceptionWindow();
- window.Setup(shortError, longError);
- window.ShowDialog();
- }
-
- /// <summary>
/// Get The Source from the CLI Query
/// </summary>
/// <param name="query">Full CLI Query</param>
diff --git a/win/CS/frmActivityWindow.cs b/win/CS/frmActivityWindow.cs index eb6f30ee1..28be0cc48 100644 --- a/win/CS/frmActivityWindow.cs +++ b/win/CS/frmActivityWindow.cs @@ -14,6 +14,7 @@ namespace Handbrake using System.Windows.Forms;
using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Services.Interfaces;
using Handbrake.Functions;
@@ -185,7 +186,7 @@ namespace Handbrake }
catch (Exception exc)
{
- Main.ShowExceptiowWindow("Error during load.", exc.ToString());
+ throw new GeneralApplicationException("Error Loading the Activity Window", string.Empty, exc);
}
}
@@ -290,7 +291,7 @@ namespace Handbrake catch (Exception exc)
{
windowTimer.Dispose();
- Main.ShowExceptiowWindow("GetLog() Error.", exc.ToString());
+ throw new GeneralApplicationException("Failed to Get Log.", string.Empty, exc);
}
return appendText;
diff --git a/win/CS/frmMain.cs b/win/CS/frmMain.cs index f7f859b2f..b1e5196fb 100644 --- a/win/CS/frmMain.cs +++ b/win/CS/frmMain.cs @@ -20,6 +20,7 @@ namespace Handbrake using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model.General;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Functions;
@@ -227,7 +228,7 @@ namespace Handbrake catch (Exception ex)
{
if ((bool)result.AsyncState)
- Main.ShowExceptiowWindow("Unable to check for updates, Please try again later.", ex.ToString());
+ throw new GeneralApplicationException("Unable to check for updates.", "Please try again later. The service may currently be down or inaccessible. ", ex);
}
}
@@ -2651,7 +2652,7 @@ namespace Handbrake }
catch (Exception exc)
{
- Main.ShowExceptiowWindow("HandBrake was not able to shutdown properly. You may need to forcefully quit HandBrake CLI from TaskManager if it's still running.", exc.ToString());
+ throw new GeneralApplicationException("HandBrake was not able to shutdown properly.", " You may need to forcefully quit HandBrake CLI from TaskManager if it's still running ", exc);
}
finally
{
diff --git a/win/CS/frmPreview.cs b/win/CS/frmPreview.cs index bcafc23a1..a9cf946ab 100644 --- a/win/CS/frmPreview.cs +++ b/win/CS/frmPreview.cs @@ -13,7 +13,9 @@ namespace Handbrake using Functions;
using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.General;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -138,7 +140,7 @@ namespace Handbrake }
catch (Exception exc)
{
- Main.ShowExceptiowWindow("An Unexpected error has occured", exc.ToString());
+ throw new GeneralApplicationException("An Unexpected error has occured", " Your encode may not have completed sucessfully.", exc);
}
}
|