[CSHARP-270] Provide usable error messages. Created: 18/Jul/11  Updated: 02/Apr/15  Resolved: 21/Jul/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2

Type: Bug Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

MongoDB.Bson.Serialization.BsonClassMapSerializer.Deserialize: generates messages like this: Unexpected element "

{0}".

What class are we deserializing? Was it unexpected on the class, or in the bson and not in the class (was it renamed by an attribute, but has a field – was it saved from an old version of the class)? What collection did this come from? What is the _id of this document?

There are other error messages in the same file like, "Anonymous class cannot be deserialized.","Value class {0}

cannot be deserialized.", "Required element '

{0}

' is missing.", of the same type.

Please provide some context for the error so that users can find their problems, and fix them.



 Comments   
Comment by Robert Stam [ 21/Jul/11 ]

Added a bit more information to the error messages as appropriate.

Comment by Robert Stam [ 19/Jul/11 ]

Because the BSON library is separate from the MongoDB driver library the name of the collection is not known at this level.

Some of the messages already contain all the available information:

"Value class

{0} cannot be deserialized."
"Anonymous class cannot be deserialized."
"SetDocumentId cannot be used with value type '{0}

'."
"Class

{0} has no Id member."
"BsonClassMapSerializer cannot be used with type {0}

."

For all of these messages there is no additional information other than the class name (and an anonymous class doesn't even have that).

I will add the requested information (class name, property name, element name, _id value) as appropriate to the rest of the error messages in this file.

Generated at Wed Feb 07 21:36:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.