diff --git a/src/Umbraco.Core/Configuration/Models/ContentSettings.cs b/src/Umbraco.Core/Configuration/Models/ContentSettings.cs index 32c4cc120d..8b1eb47b5b 100644 --- a/src/Umbraco.Core/Configuration/Models/ContentSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/ContentSettings.cs @@ -30,11 +30,15 @@ namespace Umbraco.Core.Configuration.Models { get { - return Enum.TryParse(MacroErrors, true, out var value) - ? value - : throw new InvalidOperationException( - $"Parsing of {nameof(MacroErrors)} field value of {MacroErrors} was not recognised as a valid value of the enum {nameof(MacroErrorBehaviour)}. " + - $"This state shouldn't have been reached as if the configuration contains an invalid valie it should be caught by {nameof(ContentSettingsValidator)}."); + if (Enum.TryParse(MacroErrors, true, out var value)) + { + return value; + } + + // We need to return somethhing valid here as this property is evalulated during start-up, and if there's an error + // in the configured value it won't be parsed to the enum. + // At run-time though this default won't be used, as an invalid value will be picked up by ContentSettingsValidator. + return MacroErrorBehaviour.Inline; } } diff --git a/src/Umbraco.Core/Configuration/Models/HostingSettings.cs b/src/Umbraco.Core/Configuration/Models/HostingSettings.cs index 1cd1d96e8e..a6dec1f104 100644 --- a/src/Umbraco.Core/Configuration/Models/HostingSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/HostingSettings.cs @@ -17,11 +17,15 @@ namespace Umbraco.Core.Configuration.Models { get { - return Enum.TryParse(LocalTempStorageLocation, true, out var value) - ? value - : throw new InvalidOperationException( - $"Parsing of {nameof(LocalTempStorageLocation)} field value of {LocalTempStorageLocation} was not recognised as a valid value of the enum {nameof(LocalTempStorage)}. " + - $"This state shouldn't have been reached as if the configuration contains an invalid valie it should be caught by {nameof(HostingSettingsValidator)}."); + if (Enum.TryParse(LocalTempStorageLocation, true, out var value)) + { + return value; + } + + // We need to return somethhing valid here as this property is evalulated during start-up, and if there's an error + // in the configured value it won't be parsed to the enum. + // At run-time though this default won't be used, as an invalid value will be picked up by HostingSettingsValidator. + return LocalTempStorage.Default; } } diff --git a/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs index 1f0e6612df..faabcb8290 100644 --- a/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs @@ -30,11 +30,15 @@ namespace Umbraco.Core.Configuration.Models { get { - return Enum.TryParse(ModelsMode, true, out var value) - ? value - : throw new InvalidOperationException( - $"Parsing of {nameof(ModelsMode)} field value of {ModelsMode} was not recognised as a valid value of the enum {nameof(ModelsMode)}. " + - $"This state shouldn't have been reached as if the configuration contains an invalid valie it should be caught by {nameof(ModelsBuilderSettingsValidator)}."); + if (Enum.TryParse(ModelsMode, true, out var value)) + { + return value; + } + + // We need to return somethhing valid here as this property is evalulated during start-up, and if there's an error + // in the configured value it won't be parsed to the enum. + // At run-time though this default won't be used, as an invalid value will be picked up by ModelsBuilderSettingsValidator. + return Configuration.ModelsMode.Nothing; } } diff --git a/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs b/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs index 6ac417517f..ecc3b71a78 100644 --- a/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/SmtpSettings.cs @@ -24,12 +24,15 @@ namespace Umbraco.Core.Configuration.Models { get { - return Enum.TryParse(DeliveryMethod, true, out var value) - ? value - : throw new InvalidOperationException( - $"Parsing of {nameof(DeliveryMethod)} field value of {DeliveryMethod} was not recognised as a valid value of the enum {nameof(SmtpDeliveryMethod)}. " + - $"This state shouldn't have been reached as if the configuration contains an invalid valie it should be caught by {nameof(GlobalSettingsValidator)}."); + if (Enum.TryParse(DeliveryMethod, true, out var value)) + { + return value; + } + // We need to return somethhing valid here as this property is evalulated during start-up, and if there's an error + // in the configured value it won't be parsed to the enum. + // At run-time though this default won't be used, as an invalid value will be picked up by GlobalSettingsValidator. + return SmtpDeliveryMethod.Network; } }