-
Type: Investigation
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Iteration Iguanodon
-
Not Needed
Use Case
As a driver engineer,
I want our errors to properly support the `cause` property
So that we can provide actionable errors to users.
User Impact
Should be minimal - users shouldn't be constructing MongoErrors themselves.
Dependencies
- n/a
Unknowns
- Should we take this opportunity to mark the constructors of our errors internal?
- Yes
Acceptance Criteria
Implementation Requirements
- Adjust the constructor of `MongoError` to `constructor(message: string, options: { cause?: Error })` (this matches the official Error constructor)
- Adjust subclasses of MongoError to properly call `super` with the required parameters.
- Narrow the type of the `cause` property to an `Error` for our drivers' errors.
- Remove Node14 logic to attach the cause to MongoError manually in the constructor and remove the `cause` property from the MongoError class.
- Make the constructors of all our errors internal (see open question).
- Make `MongoCryptError` a subclass of MongoError
- This was deferred until the constructor of `MongoError` properly supports a cause.
Testing Requirements
- Add tests asserting that each MongoCryptError is a subclass of MongoError.
Documentation Requirements
- Update `etc/notes/Errors.md` with new errors
Follow Up Requirements
- n/a
- depends on
-
NODE-5484 Add Node16+ support for the `cause` property in errors
- Closed