Add a type-safe way for applications to detect that a BSON document failed to serialize due to the maximum document size supported by MongoDB being exceeded. Possibilities include:
- adding an enumeration to BsonSerializationException
- adding a new exception type, e.g. BsonMaximumDocumentSizeExceedException
Original Description
While catching an exception for the error "MaxDocumentSize exceeded...", per this ref, the errorCode is not populated.
It would appear that the BsonSerializationException constructor only accepts strings, while its superclass BSONException can accept both string and a code (among its four constructors).
Looking further at the source for BsonSerializationException, all it does is call super(message) and nothing else.