From: sr55 Date: Thu, 12 Jan 2017 21:21:33 +0000 (+0000) Subject: WinGui: Put up a clearer error when we can't read older presets rather than just... X-Git-Tag: 1.1.0~785 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ff916a4f3d1031f38d5e0dfa64877f2e0407970;p=handbrake WinGui: Put up a clearer error when we can't read older presets rather than just showing a stack trace. #513 --- 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(presetJson); + if (!string.IsNullOrEmpty(presetJson)) + { + PresetTransportContainer preset = JsonConvert.DeserializeObject(presetJson); + return preset; + } - return preset; + return null; } /// 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 @@ -1154,6 +1154,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to No Additional Information. + /// + public static string NoAdditionalInformation { + get { + return ResourceManager.GetString("NoAdditionalInformation", resourceCulture); + } + } + /// /// Looks up a localized string similar to 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 Processing Pass {0} of {1}, (Subtitle Scan) {2:00.00}%, Scan Time Remaining: {3}, Elapsed: {4:d\:hh\:mm\:ss} + + No Additional Information + \ 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; }