Use when on throw on error to avoid context loss

This commit is contained in:
Matt Nadareski
2021-01-12 15:54:14 -08:00
parent 2e674e23ca
commit 3317aef790
20 changed files with 40 additions and 136 deletions

View File

@@ -88,15 +88,10 @@ namespace SabreTools.DatFiles.Formats
// Now process and add the rom
ParseAddHelper(rom, statsOnly);
}
catch (Exception ex)
catch (Exception ex) when (!throwOnError)
{
string message = $"'{filename}' - There was an error parsing at position {sr.BaseStream.Position}";
logger.Error(ex, message);
if (throwOnError)
{
sr.Dispose();
throw new Exception(message, ex);
}
}
}
@@ -160,10 +155,9 @@ namespace SabreTools.DatFiles.Formats
svw.Dispose();
fs.Dispose();
}
catch (Exception ex)
catch (Exception ex) when (!throwOnError)
{
logger.Error(ex);
if (throwOnError) throw ex;
return false;
}