Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1581

Properly wrap and provide Unwrap implementations for error types

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 1.4.0
    • Error Handling
    • None

    Description

      Go 1.13 introduced a way to unwrap errors to get to the root error cause (seeĀ https://blog.golang.org/go1.13-errors). We should add an Unwrap method to all of our error types that wrap errors and also add a Wrapped field to mongo.CommandError as the operations layer reports network errors as a driver.Error with the NetworkError label. The driver.Error type already has a wrapped field so that can be directly copied in the replaceErrors function.

      We should also change how we wrap certain errors. Specifically, when a context timeout is translated into a socket timeout, we should ensure the error returned to the user in the event of a timeout can be checked with errors.Is(err, context.DeadlineExceeded). This currently doesn't work because the user instead gets back whatever the net library returns.

      Attachments

        Activity

          People

            divjot.arora@mongodb.com Divjot Arora
            divjot.arora@mongodb.com Divjot Arora
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: