Skip to content

Commit b7e96d1

Browse files
Copilotjaviercn
andcommitted
Simplify error message and use nameof for property names
Co-authored-by: javiercn <[email protected]>
1 parent 0712e4c commit b7e96d1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Components/Components/src/Routing/Router.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public async Task SetParametersAsync(ParameterView parameters)
147147
#pragma warning disable CS0618 // Type or member is obsolete
148148
if (NotFound != null)
149149
{
150-
throw new InvalidOperationException("Both NotFound and NotFoundPage parameters are set on Router component. NotFoundPage is preferred and NotFound will be deprecated. Consider using only NotFoundPage.");
150+
throw new InvalidOperationException($"Setting {nameof(NotFound)} and {nameof(NotFoundPage)} properties simultaneously is not supported. Use either {nameof(NotFound)} or {nameof(NotFoundPage)}.");
151151
}
152152
#pragma warning restore CS0618 // Type or member is obsolete
153153
if (!typeof(IComponent).IsAssignableFrom(NotFoundPage))

src/Components/Components/test/Routing/RouterTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ public async Task ThrowsExceptionWhenBothNotFoundAndNotFoundPageAreSet()
297297
await renderer.Dispatcher.InvokeAsync(() =>
298298
router.SetParametersAsync(ParameterView.FromDictionary(parameters))));
299299

300-
Assert.Contains("Both NotFound and NotFoundPage parameters are set on Router component", exception.Message);
301-
Assert.Contains("NotFoundPage is preferred and NotFound will be deprecated", exception.Message);
300+
Assert.Contains("Setting NotFound and NotFoundPage properties simultaneously is not supported", exception.Message);
301+
Assert.Contains("Use either NotFound or NotFoundPage", exception.Message);
302302
}
303303

304304
internal class TestNavigationManager : NavigationManager

0 commit comments

Comments
 (0)