Fix a few stragglers

This commit is contained in:
Matt Nadareski
2020-09-15 14:46:39 -07:00
parent fc580c7d35
commit 74a0c47102
3 changed files with 36 additions and 61 deletions

View File

@@ -707,8 +707,9 @@ namespace SabreTools.Library.DatFiles
/// Apply cleaning methods to the DatFile
/// </summary>
/// <param name="cleaner">Cleaner to use</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if cleaning was successful, false on error</returns>
public bool ApplyCleaning(Cleaner cleaner)
public bool ApplyCleaning(Cleaner cleaner, bool throwOnError = false)
{
try
{
@@ -751,9 +752,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Error(ex);
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
return false;
}
@@ -764,8 +763,9 @@ namespace SabreTools.Library.DatFiles
/// Apply a set of Extra INIs on the DatFile
/// </summary>
/// <param name="extras">ExtrasIni to use</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the extras were applied, false on error</returns>
public bool ApplyExtras(ExtraIni extras)
public bool ApplyExtras(ExtraIni extras, bool throwOnError = false)
{
try
{
@@ -817,9 +817,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Error(ex);
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
return false;
}
@@ -831,8 +829,9 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="filter">Filter to use</param>
/// <param name="perMachine">True if entire machines are considered, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DatFile was filtered, false on error</returns>
public bool ApplyFilter(Filter filter, bool perMachine = false)
public bool ApplyFilter(Filter filter, bool perMachine = false, bool throwOnError = false)
{
// If we have a null filter, return false
if (filter == null)
@@ -891,9 +890,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Error(ex);
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
return false;
}
@@ -905,8 +902,9 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="splitType">Split type to try</param>
/// <param name="useTags">True if DatFile tags override splitting, false otherwise</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DatFile was split, false on error</returns>
public bool ApplySplitting(MergingFlag splitType, bool useTags)
public bool ApplySplitting(MergingFlag splitType, bool useTags, bool throwOnError = false)
{
try
{
@@ -940,9 +938,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Error(ex);
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
return false;
}
@@ -1011,7 +1007,8 @@ namespace SabreTools.Library.DatFiles
/// <summary>
/// Use game descriptions as names in the DAT, updating cloneof/romof/sampleof
/// </summary>
public void MachineDescriptionToName()
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public void MachineDescriptionToName(bool throwOnError = false)
{
try
{
@@ -1062,8 +1059,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Warning(ex.ToString());
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
}
}
@@ -3527,8 +3523,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Error(ex, $"Datfile {outfile} could not be written out");
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
}
});
@@ -3536,9 +3531,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Error(ex);
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
return false;
}

View File

@@ -139,9 +139,7 @@ namespace SabreTools.Library.DatFiles
catch (Exception ex)
{
Globals.Logger.Error(ex);
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
return false;
}
@@ -153,10 +151,7 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="svw">SeparatedValueWriter to output to</param>
/// <param name="datItem">DatItem object to be output</param>
/// <returns>True if the data was written, false on error</returns>
private bool WriteDatItem(SeparatedValueWriter svw, DatItem datItem)
{
try
private void WriteDatItem(SeparatedValueWriter svw, DatItem datItem)
{
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
@@ -187,16 +182,5 @@ namespace SabreTools.Library.DatFiles
svw.Flush();
}
catch (Exception ex)
{
Globals.Logger.Error(ex);
if (Globals.ThrowOnError)
throw ex;
return false;
}
return true;
}
}
}

View File

@@ -66,9 +66,7 @@ namespace SabreTools.Library.DatFiles
catch (InvalidDataException ex)
{
Globals.Logger.Warning($"Malformed line found in '{filename}' at line {svr.LineNumber}");
if (Globals.ThrowOnError)
throw ex;
if (throwOnError) throw ex;
continue;
}