-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongo driver 4 rc fix duplicate error #95
base: mongo-driver-4-rc
Are you sure you want to change the base?
Mongo driver 4 rc fix duplicate error #95
Conversation
Codecov Report
@@ Coverage Diff @@
## mongo-driver-4-rc #95 +/- ##
=====================================================
+ Coverage 87.08% 88.50% +1.42%
=====================================================
Files 8 8
Lines 813 870 +57
=====================================================
+ Hits 708 770 +62
+ Misses 105 100 -5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
MDBE_WRITE_CONCERN_ERROR, | ||
WRITE_CONCERN_ERROR, | ||
WRITE_ERROR | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 to adding all these, we should only add what we need (and we haven't needed any of these) -- otherwise it's just more to maintain and test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. There might be an automated way of adding these though. I'll look into it and if not cut them down to something more manageable. I also think not all of these errors are root errors, many of them are the cause of a MongoError
I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I looked into this today and basically here is the problem: MongoError
seems to be nothing more than an abstract class, then MongoError
in turn has about 5-6 errors that derive from it, then those 5-6 errors in turn throw the errors listed above and are base classes for a panoply of different errors. So we can pretty safely remove MongoError
, but the issue is the driver throws most of the other errors so we probably do need to ensure we know their names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so I trimmed this down to just the two errors that are kind of sort of thrown by the driver that are not MongoError
s. Then I added a new function assertMongoError
here: 43ab9b0
and here:
94bf529
This method should work as the node mongo driver is now written using typescript so there are a lot of Abstract base classes and inheritance based type checking structures that ultimately result in 3 cases: either you get a MongoError
, a WriteError
or WriteConcernError
. For the most part you only get MongoError
, but documents can contain WriteError
and MongoError
can contain both WriteError
or WriteConcernError
so there might be edge cases were we're asserting on the cause of a MongoError
or on the writeErrors
property of MongoError
or document
.
94bf529
to
4ea8316
Compare
MongoError
.