Index: Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/RingtoetsWellKnownTileSourceExtension.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rca0345432ea951a80e3e956a8d485840c0897e1d --- Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/RingtoetsWellKnownTileSourceExtension.cs (.../RingtoetsWellKnownTileSourceExtension.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/RingtoetsWellKnownTileSourceExtension.cs (.../RingtoetsWellKnownTileSourceExtension.cs) (revision ca0345432ea951a80e3e956a8d485840c0897e1d) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.ComponentModel; using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.AssessmentSection @@ -35,10 +36,19 @@ /// The /// to get the display name of. /// The display name. - /// Thrown when - /// is not a valid value for . + /// Thrown when + /// is not a valid value of . + /// Thrown when + /// is not supported. public static string GetDisplayName(this RingtoetsWellKnownTileSource ringtoetsWellKnownTileSource) { + if (!Enum.IsDefined(typeof(RingtoetsWellKnownTileSource), ringtoetsWellKnownTileSource)) + { + throw new InvalidEnumArgumentException(nameof(ringtoetsWellKnownTileSource), + (int)ringtoetsWellKnownTileSource, + typeof(RingtoetsWellKnownTileSource)); + } + switch (ringtoetsWellKnownTileSource) { case RingtoetsWellKnownTileSource.OpenStreetMap: @@ -54,7 +64,7 @@ case RingtoetsWellKnownTileSource.EsriWorldShadedRelief: return Resources.RingtoetsWellKnownTileSource_EsriWorldShadedRelief_DisplayName; default: - throw new NotSupportedException($"Unknown value '{ringtoetsWellKnownTileSource}'"); + throw new NotSupportedException($"The enum value {nameof(RingtoetsWellKnownTileSource)}.{ringtoetsWellKnownTileSource} is not supported."); } } }