Fix photo uploading and add more detailed logging to deserialization

This commit is contained in:
Slendy 2023-02-24 20:17:44 -06:00
commit a2d2337dc3
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 8 additions and 4 deletions

View file

@ -102,8 +102,9 @@ public static partial class ControllerExtensions
if (matchedRoot == null) if (matchedRoot == null)
{ {
Logger.Error($"[{controller.ControllerContext.ActionDescriptor.ActionName}] " + Logger.Error($"[{controller.ControllerContext.ActionDescriptor.ActionName}] " +
$"Failed to deserialize {typeof(T).Name}: Unable to match root element", LogArea.Deserialization); $"Failed to deserialize {typeof(T).Name}: Unable to match root element\n" +
Logger.Error($"{bodyString}", LogArea.Deserialization); $"xmlData: '{bodyString}'",
LogArea.Deserialization);
return default; return default;
} }
root = new XmlRootAttribute(matchedRoot); root = new XmlRootAttribute(matchedRoot);
@ -116,8 +117,10 @@ public static partial class ControllerExtensions
catch (Exception e) catch (Exception e)
{ {
Logger.Error($"[{controller.ControllerContext.ActionDescriptor.ActionName}] " + Logger.Error($"[{controller.ControllerContext.ActionDescriptor.ActionName}] " +
$"Failed to deserialize {typeof(T).Name}: {e.Message}", LogArea.Deserialization); $"Failed to deserialize {typeof(T).Name}:\n" +
Logger.Error($"{bodyString}", LogArea.Deserialization); $"xmlData: '{bodyString}'\n" +
$"detailedException: '{e.ToDetailedException()}",
LogArea.Deserialization);
} }
return default; return default;
} }

View file

@ -60,6 +60,7 @@ public class Photo
[XmlElement("plan")] [XmlElement("plan")]
public string PlanHash { get; set; } = ""; public string PlanHash { get; set; } = "";
[XmlIgnore]
public virtual ICollection<PhotoSubject> PhotoSubjects { get; set; } = new HashSet<PhotoSubject>(); public virtual ICollection<PhotoSubject> PhotoSubjects { get; set; } = new HashSet<PhotoSubject>();
public int CreatorId { get; set; } public int CreatorId { get; set; }