Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs =================================================================== diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r9f9b40be8a207b1d4ff944bee747f472a64077a7 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 9f9b40be8a207b1d4ff944bee747f472a64077a7) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; using Ringtoets.Common.IO.Exceptions; using Ringtoets.Common.IO.SoilProfile; @@ -89,7 +90,8 @@ } catch (ArgumentException e) { - throw new ImportedDataTransformException(e.Message, e); + string message = CreateErrorMessage(soilProfile.Name, e.Message); + throw new ImportedDataTransformException(message, e); } } @@ -109,14 +111,41 @@ soilProfile.Layers .Select(MacroStabilityInwardsSoilLayerTransformer.Transform) .ToArray(), - soilProfile.PreconsolidationStresses - .Select(MacroStabilityInwardsPreconsolidationStressTransformer.Transform) - .ToArray()); + TransformPreconsolidationStresses(soilProfile.Name, soilProfile.PreconsolidationStresses)); } catch (ArgumentException e) { - throw new ImportedDataTransformException(e.Message, e); + string message = CreateErrorMessage(soilProfile.Name, e.Message); + throw new ImportedDataTransformException(message, e); } } + + /// + /// Transforms the generic collection of into a . + /// + /// The name of the soil profile. + /// The collection of to transform. + /// An based on . + /// Thrown when the + /// could not be transformed into valid . + private static IEnumerable TransformPreconsolidationStresses(string soilProfileName, + IEnumerable preconsolidationStresses) + { + try + { + return preconsolidationStresses.Select(MacroStabilityInwardsPreconsolidationStressTransformer.Transform) + .ToArray(); + } + catch (ImportedDataTransformException e) + { + string message = CreateErrorMessage(soilProfileName, e.Message); + throw new ImportedDataTransformException(message, e); + } + } + + private static string CreateErrorMessage(string soilProfileName, string errorMessage) + { + return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilProfile_0_ErrorMessage_1_, soilProfileName, errorMessage); + } } } \ No newline at end of file