Improve err handling a little

This commit is contained in:
Nikolaj Olsson 2023-12-16 12:00:46 +01:00
parent 09770e74a9
commit 284592b1e9
3 changed files with 48 additions and 12 deletions

View File

@ -3,7 +3,7 @@
4.0.3 (xth December 2023) BETA
* NEW:
* Add ".opus" audio file extension - thx vivadavid
* Add ".opus" / ".adts" audio file extensions - thx vivadavid/Lyubomir71
* Add two TSV subtitle formats - thx Purfview
* Add Arabic translation - thx Yahya
* Add new json subtitle format - thx Lucretia
@ -27,6 +27,8 @@
* Re-add Whisper Const-me large model v2
* Audio-to-text: Improve error msg if no write access to video source folder
* Add delay in seconds to translate via ChatGPT
* Toggle music symbols, now toggles via first text - thx Leon
* Use source video folder when saving hard-sub video - thx Leon
* FIXED:
* Fix for BDSUP cmd line convert - thx Jack1789
* Do not count HTML tags in SCC in save/load - thx cs127

View File

@ -0,0 +1,7 @@
<NoBreakAfterList>
<Item>Dr</Item>
<Item>Dr.</Item>
<Item>Mr.</Item>
<Item>Mrs.</Item>
<Item>Ms.</Item>
</NoBreakAfterList>

View File

@ -1,9 +1,9 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.Forms;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core.Forms;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
{
@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
var language = LanguageSettings.Current.BeautifyTimeCodesProfile;
Text = language.CreateSimpleTitle;
labelInstructions.Text = language.CreateSimpleInstruction;
@ -84,9 +84,18 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
DialogResult = DialogResult.None;
return;
}
// Save settings
var gap = Convert.ToInt32(numericUpDownGap.Value);
int gap;
try
{
gap = Convert.ToInt32(numericUpDownGap.Value);
}
catch (Exception exception)
{
throw new Exception($"Unable to set gap from numericUpDownGap.Value to Int32: numericUpDownGap.Value = '{numericUpDownGap.Value}'", exception);
}
var inCuesGap = comboBoxInCues.SelectedIndex;
var outCuesGap = comboBoxOutCues.SelectedIndex;
if (comboBoxOutCues.SelectedIndex == comboBoxOutCues.Items.Count - 1)
@ -94,10 +103,28 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
outCuesGap = gap;
}
var redZone = Convert.ToInt32(numericUpDownOffset.Value);
var greenZone = Convert.ToInt32(numericUpDownSafeZone.Value);
int redZone;
try
{
redZone = Convert.ToInt32(numericUpDownOffset.Value);
}
catch (Exception exception)
{
throw new Exception($"Unable to set redZone from numericUpDownOffset.Value to Int32: numericUpDownOffset.Value = '{numericUpDownOffset.Value}'", exception);
}
Configuration.Settings.BeautifyTimeCodes.Profile.Gap = Convert.ToInt32(numericUpDownGap.Value);
int greenZone;
try
{
greenZone = Convert.ToInt32(numericUpDownSafeZone.Value);
}
catch (Exception exception)
{
throw new Exception($"Unable to set greenZone from numericUpDownSafeZone.Value to Int32: numericUpDownSafeZone.Value = '{numericUpDownSafeZone.Value}'", exception);
}
Configuration.Settings.BeautifyTimeCodes.Profile.Gap = gap;
Configuration.Settings.BeautifyTimeCodes.Profile.InCuesGap = inCuesGap;
Configuration.Settings.BeautifyTimeCodes.Profile.InCuesLeftGreenZone = greenZone;
@ -132,7 +159,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs);
throw;
throw new Exception($"Unable to calculate treadConnectedMs from gap '{gap}' and frame rate {_frameRate}", exception);
}
try
@ -145,7 +172,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs);
throw;
throw new Exception($"Unable to set ConnectedSubtitlesTreatConnected from treadConnectedMs '{treadConnectedMs}'", exception);
}
Configuration.Settings.BeautifyTimeCodes.Profile.ChainingGeneralUseZones = false;
@ -175,7 +202,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
private void numericUpDownGap_ValueChanged(object sender, EventArgs e)
{
int gapFrames = Convert.ToInt32(numericUpDownGap.Value);
var gapFrames = Convert.ToInt32(numericUpDownGap.Value);
double gapMs = SubtitleFormat.FramesToMilliseconds(gapFrames, _frameRate);
labelGapHint.Text = string.Format(LanguageSettings.Current.BeautifyTimeCodesProfile.GapInMsFormat, Math.Round(gapMs), Math.Round(_frameRate, 3));