Let exceptions boil up

This commit is contained in:
Matt Nadareski
2023-07-30 09:00:15 -04:00
parent 9ae8036b0a
commit 378f9cbfd1
15 changed files with 1107 additions and 1321 deletions

View File

@@ -16,16 +16,8 @@ namespace SabreTools.Serialization
/// <returns>Deserialized data on success, null on failure</returns>
public static T? Deserialize(string path)
{
try
{
using var stream = PathProcessor.OpenStream(path);
return Deserialize(stream);
}
catch
{
// TODO: Handle logging the exception
return default;
}
using var stream = PathProcessor.OpenStream(path);
return Deserialize(stream);
}
/// <summary>
@@ -35,30 +27,22 @@ namespace SabreTools.Serialization
/// <returns>Deserialized data on success, null on failure</returns>
public static T? Deserialize(Stream? stream)
{
try
{
// If the stream is null
if (stream == null)
return default;
// Setup the serializer and the reader
var serializer = new XmlSerializer(typeof(T));
var settings = new XmlReaderSettings
{
CheckCharacters = false,
DtdProcessing = DtdProcessing.Ignore,
};
var streamReader = new StreamReader(stream);
var xmlReader = XmlReader.Create(streamReader, settings);
// Perform the deserialization and return
return (T?)serializer.Deserialize(xmlReader);
}
catch
{
// TODO: Handle logging the exception
// If the stream is null
if (stream == null)
return default;
}
// Setup the serializer and the reader
var serializer = new XmlSerializer(typeof(T));
var settings = new XmlReaderSettings
{
CheckCharacters = false,
DtdProcessing = DtdProcessing.Ignore,
};
var streamReader = new StreamReader(stream);
var xmlReader = XmlReader.Create(streamReader, settings);
// Perform the deserialization and return
return (T?)serializer.Deserialize(xmlReader);
}
}
}