From 15352bec1002c8c2d04f9481b1691c1a27fa82b6 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 12 Dec 2023 15:10:38 -0800 Subject: [PATCH] Fix the error exception message (#14889) --- .../Services/ContentDefinitionService.cs | 6 +++--- .../OrchardCore.Roles/ViewModels/PermissionGroupKey.cs | 2 +- .../Extensions/Utility/DependencyOrdering.cs | 2 +- .../Configuration/TenantJsonConfigurationExtensions.cs | 2 +- .../Utilities/ControllerTypeExtensions.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Services/ContentDefinitionService.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Services/ContentDefinitionService.cs index 660da6d2bab..fc4efad29c6 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Services/ContentDefinitionService.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Services/ContentDefinitionService.cs @@ -97,7 +97,7 @@ public async Task AddTypeAsync(string name, string displa { if (string.IsNullOrWhiteSpace(displayName)) { - throw new ArgumentException("The 'displayName' can't be null or empty.", nameof(displayName)); + throw new ArgumentException($"The '{nameof(displayName)}' can't be null or empty.", nameof(displayName)); } if (string.IsNullOrWhiteSpace(name)) @@ -322,7 +322,7 @@ public async Task AddFieldToPartAsync(string fieldName, string displayName, stri { if (string.IsNullOrEmpty(fieldName)) { - throw new ArgumentException("The '{fieldName}' can't be null or empty.", nameof(fieldName)); + throw new ArgumentException($"The '{nameof(fieldName)}' can't be null or empty.", nameof(fieldName)); } var partDefinition = await _contentDefinitionManager.LoadPartDefinitionAsync(partName); @@ -398,7 +398,7 @@ public Task AlterTypePartsOrderAsync(ContentTypeDefinition typeDefinition, strin for (var i = 0; i < partNames.Length; i++) { var partDefinition = typeDefinition.Parts?.FirstOrDefault(x => x.Name == partNames[i]); - + if (partDefinition == null) { continue; diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs b/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs index ed3228c6fb4..2a30f9ebe0f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs @@ -14,7 +14,7 @@ public PermissionGroupKey(string key) { if (string.IsNullOrWhiteSpace(key)) { - throw new ArgumentException("The 'key' cannot be null or empty", nameof(key)); + throw new ArgumentException($"The '{nameof(key)}' cannot be null or empty", nameof(key)); } Key = key; diff --git a/src/OrchardCore/OrchardCore.Abstractions/Extensions/Utility/DependencyOrdering.cs b/src/OrchardCore/OrchardCore.Abstractions/Extensions/Utility/DependencyOrdering.cs index 09200a7b256..2b6f19d5466 100644 --- a/src/OrchardCore/OrchardCore.Abstractions/Extensions/Utility/DependencyOrdering.cs +++ b/src/OrchardCore/OrchardCore.Abstractions/Extensions/Utility/DependencyOrdering.cs @@ -77,7 +77,7 @@ private static void MoveUp(List list, int index, int lowerIndex) { if (index < lowerIndex) { - throw new ArgumentException("Should be higher or equal to 'lowerIndex'.", nameof(index)); + throw new ArgumentException($"Should be higher or equal to '{nameof(lowerIndex)}'.", nameof(index)); } if (index != lowerIndex) diff --git a/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationExtensions.cs b/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationExtensions.cs index 63bc9c0d058..1fd5fce5483 100644 --- a/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationExtensions.cs +++ b/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationExtensions.cs @@ -72,7 +72,7 @@ public static IConfigurationBuilder AddTenantJsonFile(this IConfigurationBuilder if (string.IsNullOrEmpty(path)) { // throw new ArgumentException(SR.Error_InvalidFilePath, nameof(path)); - throw new ArgumentException($"File path must be a non-empty string.", nameof(path)); + throw new ArgumentException("File path must be a non-empty string.", nameof(path)); } return builder.AddTenantJsonFile(s => diff --git a/src/OrchardCore/OrchardCore.Mvc.Core/Utilities/ControllerTypeExtensions.cs b/src/OrchardCore/OrchardCore.Mvc.Core/Utilities/ControllerTypeExtensions.cs index 77b0a34245d..f47b346c06d 100644 --- a/src/OrchardCore/OrchardCore.Mvc.Core/Utilities/ControllerTypeExtensions.cs +++ b/src/OrchardCore/OrchardCore.Mvc.Core/Utilities/ControllerTypeExtensions.cs @@ -9,7 +9,7 @@ public static string ControllerName(this Type controllerType) { if (!typeof(Controller).IsAssignableFrom(controllerType)) { - throw new ArgumentException("The specified type must inherit from " + nameof(Controller), nameof(controllerType)); + throw new ArgumentException($"The specified type must inherit from '{nameof(Controller)}'", nameof(controllerType)); } return controllerType.Name.EndsWith(nameof(Controller), StringComparison.OrdinalIgnoreCase)