[CSHARP-400] Improve error message in SetIdMember when memberMap argument is for a different class Created: 17/Feb/12 Updated: 02/Apr/15 Resolved: 18/Feb/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.3.1 |
| Fix Version/s: | 1.4 |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Robert Stam | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Minor Change | ||||||||||||
| Description |
|
When SetIdMember is called with a memberMap argument that is for a different class the current error message is too cryptic. This can be reproduced using these classes:
and this code:
The call to SetIdMember is incorrect because it is being called when registering class C but Id is defined in class B. SetIdMember should have been called when registering class B instead. The current error message "Invalid memberMap." is too cryptic. A better error message would provide more of an explanation of what is wrong. |
| Comments |
| Comment by Robert Stam [ 18/Feb/12 ] | ||
|
Could be backward breaking if you were relying on the type of the exception thrown or the text of the error message. Not likely since you would never pass invalid arguments on purpose. | ||
| Comment by Robert Stam [ 18/Feb/12 ] | ||
|
The new error message for methods that take a memberMap argument is:
A similar error message was added for methods that take a memberInfo argument:
The exception is now of type ArgumentOutOfRangeException. All methods now throw ArgumentNullException if called with a null argument (before they ended up throwing a NullReferenceException). |