mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Consolidate some of the throws
This commit is contained in:
@@ -92,9 +92,6 @@ namespace SabreTools.Library.IO
|
||||
catch (Exception ex)
|
||||
{
|
||||
Globals.Logger.Error(ex, $"An exception occurred getting the full path for '{input}'");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -109,15 +106,11 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
catch (PathTooLongException ex)
|
||||
{
|
||||
Globals.Logger.Warning($"The path for '{dir}' was too long");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
Globals.Logger.Warning(ex, $"The path for '{dir}' was too long");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Globals.Logger.Error(ex, $"An exception occurred processing '{dir}'");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,9 +188,6 @@ namespace SabreTools.Library.IO
|
||||
catch (Exception ex)
|
||||
{
|
||||
Globals.Logger.Error(ex, $"An exception occurred getting the full path for '{input}'");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -212,15 +202,11 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
catch (PathTooLongException ex)
|
||||
{
|
||||
Globals.Logger.Warning($"The path for '{file}' was too long");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
Globals.Logger.Warning(ex, $"The path for '{file}' was too long");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Globals.Logger.Error(ex, $"An exception occurred processing '{file}'");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,15 +218,11 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
catch (PathTooLongException ex)
|
||||
{
|
||||
Globals.Logger.Warning($"The path for '{input}' was too long");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
Globals.Logger.Warning(ex, $"The path for '{input}' was too long");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Globals.Logger.Error(ex, $"An exception occurred processing '{input}'");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,9 +189,7 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
|
||||
Globals.Logger.Warning(ex, $"An exception occurred trying to figure out the format of '{filename}'");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -303,9 +301,7 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Don't log file open errors
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
Globals.Logger.Warning(ex, $"An exception occurred determining file type of '{input}'");
|
||||
}
|
||||
|
||||
return outFileType;
|
||||
|
||||
@@ -194,9 +194,7 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
|
||||
Globals.Logger.Warning(ex, "An exception occurred during hashing.");
|
||||
return new BaseFile();
|
||||
}
|
||||
finally
|
||||
@@ -231,15 +229,11 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
Globals.Logger.Verbose("Stream does not support seeking to starting offset. Stream position not changed");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
Globals.Logger.Verbose(ex, "Stream does not support seeking to starting offset. Stream position not changed");
|
||||
}
|
||||
catch (NotImplementedException ex)
|
||||
{
|
||||
Globals.Logger.Warning("Stream does not support seeking to starting offset. Stream position not changed");
|
||||
if (Globals.ThrowOnError)
|
||||
throw ex;
|
||||
Globals.Logger.Warning(ex, "Stream does not support seeking to starting offset. Stream position not changed");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user