Skip to content

Commit 80a6875

Browse files
committed
Throw better exception in corner cases
1 parent d94b2e5 commit 80a6875

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/JsonApiDotNetCore.Annotations/Configuration/ResourceType.cs

-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ public AttrAttribute GetAttributeByPublicName(string publicName)
173173
public AttrAttribute GetAttributeByPropertyName(string propertyName)
174174
{
175175
AttrAttribute? attribute = FindAttributeByPropertyName(propertyName);
176-
177176
return attribute ?? throw new InvalidOperationException($"Attribute for property '{propertyName}' does not exist on resource type '{ClrType.Name}'.");
178177
}
179178

src/JsonApiDotNetCore/Configuration/ApplicationBuilderExtensions.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using JsonApiDotNetCore.Errors;
12
using JsonApiDotNetCore.Middleware;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.Extensions.DependencyInjection;
@@ -60,7 +61,7 @@ private static void AssertAspNetCoreOpenApiIsNotRegistered(IServiceProvider serv
6061

6162
if (configureInstance != null)
6263
{
63-
throw new InvalidOperationException("JsonApiDotNetCore is incompatible with ASP.NET OpenAPI. " +
64+
throw new InvalidConfigurationException("JsonApiDotNetCore is incompatible with ASP.NET OpenAPI. " +
6465
"Replace 'services.AddOpenApi()' with 'services.AddOpenApiForJsonApi()' from the JsonApiDotNetCore.OpenApi.Swashbuckle NuGet package.");
6566
}
6667
}

src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ private static void AssertNoInfiniteRecursion(int recursionDepth)
455455
{
456456
if (recursionDepth >= 500)
457457
{
458-
throw new InvalidOperationException("Infinite recursion detected in eager-load chain.");
458+
throw new InvalidConfigurationException("Infinite recursion detected in eager-load chain.");
459459
}
460460
}
461461

0 commit comments

Comments
 (0)