-
Notifications
You must be signed in to change notification settings - Fork 4
Mongo driver 4 rc fix duplicate error #95
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
Closed
aljones15
wants to merge
6
commits into
mongo-driver-4-rc
from
mongo-driver-4-rc-fix-duplicate-error
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ce754d
Fix duplicate error check.
aljones15 7eec30a
Add more Mongo Driver Errors to exceptions.
aljones15 91aa399
Add remaining Mongo Error Types.
aljones15 ea8333d
Remove abstract base classes from exceptions.
aljones15 3ba0b56
Use assertMongoError.
aljones15 4ea8316
Update assertMongoError to handle Write & WriteConcern Error.
aljones15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
MongoErrorI believe.Uh oh!
There was an error while loading. Please reload this page.
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:
MongoErrorseems to be nothing more than an abstract class, thenMongoErrorin 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 removeMongoError, but the issue is the driver throws most of the other errors so we probably do need to ensure we know their names.Uh oh!
There was an error while loading. Please reload this page.
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
MongoErrors. Then I added a new functionassertMongoErrorhere: 43ab9b0and 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, aWriteErrororWriteConcernError. For the most part you only getMongoError, but documents can containWriteErrorandMongoErrorcan contain bothWriteErrororWriteConcernErrorso there might be edge cases were we're asserting on the cause of aMongoErroror on thewriteErrorsproperty ofMongoErrorordocument.