Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1578

Investigate changes in NODE-5484: Add Node16+ support for the `cause` property in errors

    • Type: Icon: Investigation Investigation
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.0
    • Affects Version/s: None
    • Component/s: None
    • 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

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: