diff --git a/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreInsertListener.cs b/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreInsertListener.cs index 487f27697c..2bfbd6c650 100644 --- a/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreInsertListener.cs +++ b/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreInsertListener.cs @@ -59,20 +59,29 @@ public bool OnPreInsert(PreInsertEvent @event) if (_serializationEnabled) { - var lastModifiedDate = persister.Get(@event.State, ColumnNames.LastModifiedDate); - aggregateRoot.LastModifiedDate = lastModifiedDate; - aggregateRoot.CreateDate = createDate; + try + { + var lastModifiedDate = persister.Get(@event.State, ColumnNames.LastModifiedDate); + aggregateRoot.LastModifiedDate = lastModifiedDate; + aggregateRoot.CreateDate = createDate; - // Produce the serialized data - var resourceData = MessagePackHelper.SerializeAndCompressAggregateData(aggregateRoot); - aggregateRoot.AggregateData = resourceData; + // Produce the serialized data + var resourceData = MessagePackHelper.SerializeAndCompressAggregateData(aggregateRoot); + aggregateRoot.AggregateData = resourceData; - // Update the state - persister.Set(@event.State, ColumnNames.AggregateData, aggregateRoot.AggregateData); + // Update the state + persister.Set(@event.State, ColumnNames.AggregateData, aggregateRoot.AggregateData); - if (_logger.IsDebugEnabled) + if (_logger.IsDebugEnabled) + { + _logger.Debug($"MessagePack bytes for updated entity: {resourceData.Length:N0}"); + } + } + catch (Exception ex) { - _logger.Debug($"MessagePack bytes for updated entity: {resourceData.Length:N0}"); + _logger.Error($"An unexpected error occurred while serializing entity data on entity '{@event.Entity.GetType().Name}'...", ex); + + throw; } } } diff --git a/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreUpdateListener.cs b/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreUpdateListener.cs index b4dca5c333..29833340ab 100644 --- a/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreUpdateListener.cs +++ b/Application/EdFi.Ods.Common/Infrastructure/Listeners/EdFiOdsPreUpdateListener.cs @@ -38,22 +38,31 @@ public bool OnPreUpdate(PreUpdateEvent @event) { if (@event.Entity is AggregateRootWithCompositeKey aggregateRoot) { - var persister = @event.Persister; + try + { + var persister = @event.Persister; - // Update the entity with the last modified date before serializing - var lastModifiedDate = persister.Get(@event.State, ColumnNames.LastModifiedDate); - aggregateRoot.LastModifiedDate = lastModifiedDate; + // Update the entity with the last modified date before serializing + var lastModifiedDate = persister.Get(@event.State, ColumnNames.LastModifiedDate); + aggregateRoot.LastModifiedDate = lastModifiedDate; - // Produce the serialized data - var aggregateData = MessagePackHelper.SerializeAndCompressAggregateData(aggregateRoot); - aggregateRoot.AggregateData = aggregateData; + // Produce the serialized data + var aggregateData = MessagePackHelper.SerializeAndCompressAggregateData(aggregateRoot); + aggregateRoot.AggregateData = aggregateData; - // Update the state - persister.Set(@event.State, ColumnNames.AggregateData, aggregateRoot.AggregateData); + // Update the state + persister.Set(@event.State, ColumnNames.AggregateData, aggregateRoot.AggregateData); - if (_logger.IsDebugEnabled) + if (_logger.IsDebugEnabled) + { + _logger.Debug($"MessagePack bytes for updated entity: {aggregateData.Length:N0}"); + } + } + catch (Exception ex) { - _logger.Debug($"MessagePack bytes for updated entity: {aggregateData.Length:N0}"); + _logger.Error($"An unexpected error occurred while serializing entity data on entity '{@event.Entity.GetType().Name}'...", ex); + + throw; } } }