Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs
===================================================================
diff -u -r38940fd430501da3c19ac8c90f660b21f8938909 -r117a54dfd9b5972086a1f3386923edda2e7a334b
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 38940fd430501da3c19ac8c90f660b21f8938909)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 117a54dfd9b5972086a1f3386923edda2e7a334b)
@@ -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