Skip to content

Commit 4f517a0

Browse files
author
Chris Santero
committed
improve error message when attempting to re-register a type
1 parent 9449a98 commit 4f517a0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

JSONAPI/Core/ResourceTypeRegistry.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ public void AddRegistration(IResourceTypeRegistration registration)
5757
throw new InvalidOperationException(String.Format("The type `{0}` has already been registered.",
5858
registration.Type.FullName));
5959

60-
if (_registrationsByName.ContainsKey(registration.ResourceTypeName))
60+
IResourceTypeRegistration existingRegistration;
61+
if (_registrationsByName.TryGetValue(registration.ResourceTypeName, out existingRegistration))
6162
throw new InvalidOperationException(
62-
String.Format("The resource type name `{0}` has already been registered.",
63-
registration.ResourceTypeName));
63+
String.Format("Could not register `{0} under resource type name `{1}` because `{1}` has already been registered by `{2}`.",
64+
registration.Type.FullName,
65+
registration.ResourceTypeName,
66+
existingRegistration.Type.FullName));
6467

6568
_registrationsByType.Add(registration.Type, registration);
6669
_registrationsByName.Add(registration.ResourceTypeName, registration);

0 commit comments

Comments
 (0)