Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs
===================================================================
diff -u -r4136a0156ea9e20e7e1aca569c5e89cbc713fed2 -r9adb7863b832fbef7249803d20750688061c846e
--- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs (.../ConfigurationReader.cs) (revision 4136a0156ea9e20e7e1aca569c5e89cbc713fed2)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs (.../ConfigurationReader.cs) (revision 9adb7863b832fbef7249803d20750688061c846e)
@@ -50,7 +50,13 @@
///
/// The file path to the XML file.
/// A string representing an XML Schema Definition (XSD).
- /// Thrown when is invalid.
+ /// Thrown when:
+ ///
+ /// - is invalid.
+ /// - is null or empty.
+ /// - contains an invalid schema definition.
+ ///
+ ///
/// Thrown when:
///
/// - points to a file that does not exist.
@@ -62,6 +68,11 @@
{
IOUtils.ValidateFilePath(xmlFilePath);
+ if (string.IsNullOrWhiteSpace(schemaString))
+ {
+ throw new ArgumentException(nameof(schemaString));
+ }
+
ValidateFileExists(xmlFilePath);
xmlDocument = LoadDocument(xmlFilePath);
@@ -136,10 +147,19 @@
private static void ValidateToSchema(XDocument document, string schemaString, string xmlFilePath)
{
var xmlSchemaSet = new XmlSchemaSet();
- xmlSchemaSet.Add(XmlSchema.Read(new StringReader(schemaString), null));
try
{
+ xmlSchemaSet.Add(XmlSchema.Read(new StringReader(schemaString), null));
+ }
+ catch (Exception exception) when (exception is XmlException
+ || exception is XmlSchemaException)
+ {
+ throw new ArgumentException($"Invalid 'schemaString': {exception.Message}", exception);
+ }
+
+ try
+ {
document.Validate(xmlSchemaSet, null);
}
catch (XmlSchemaValidationException exception)