diff options
author | sr55 <[email protected]> | 2017-01-12 21:21:33 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2017-01-12 21:21:33 +0000 |
commit | 1ff916a4f3d1031f38d5e0dfa64877f2e0407970 (patch) | |
tree | 2fe3c2ddcad132194de2fd7b588a43cce82a1d40 /win | |
parent | cd858bced3ec13da9ff25d935b8c5166ad9a60b7 (diff) |
WinGui: Put up a clearer error when we can't read older presets rather than just showing a stack trace. #513
Diffstat (limited to 'win')
4 files changed, 29 insertions, 5 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs index 7e1f95d3e..38ebb3515 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs @@ -62,12 +62,15 @@ namespace HandBrake.ApplicationServices.Interop {
IntPtr presetStringPointer = HBFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));
string presetJson = Marshal.PtrToStringAnsi(presetStringPointer);
-
log.LogMessage(presetJson, LogMessageType.API, LogLevel.Debug);
- PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);
+ if (!string.IsNullOrEmpty(presetJson))
+ {
+ PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);
+ return preset;
+ }
- return preset;
+ return null;
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index aec34eaeb..d21853449 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -1155,6 +1155,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to No Additional Information.
+ /// </summary>
+ public static string NoAdditionalInformation {
+ get {
+ return ResourceManager.GetString("NoAdditionalInformation", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Notice.
/// </summary>
public static string Notice {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 0fae87bf4..ed52a4a8f 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -830,4 +830,7 @@ Your preset file will be archived and new one created. You will need to re-creat <data name="MainViewModel_EncodeStatusChanged_SubScan_StatusLabel" xml:space="preserve">
<value>Processing Pass {0} of {1}, (Subtitle Scan) {2:00.00}%, Scan Time Remaining: {3}, Elapsed: {4:d\:hh\:mm\:ss}</value>
</data>
+ <data name="NoAdditionalInformation" xml:space="preserve">
+ <value>No Additional Information</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index 6869b89a2..78387e54e 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -142,11 +142,20 @@ namespace HandBrakeWPF.Services.Presets {
if (!string.IsNullOrEmpty(filename))
{
- PresetTransportContainer container = HandBrakePresetService.GetPresetFromFile(filename);
+ PresetTransportContainer container = null;
+ try
+ {
+ container = HandBrakePresetService.GetPresetFromFile(filename);
+ }
+ catch (Exception exc)
+ {
+ this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, exc);
+ return;
+ }
if (container?.PresetList == null || container.PresetList.Count == 0)
{
- this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, string.Empty);
+ this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, Resources.NoAdditionalInformation);
return;
}
|