I think this should be BSON::InvalidDocument instead of the more generic BSON::BSONError as its specifically meant to catch serialization problems.