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

Properly wrap and provide Unwrap implementations for error types

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.0
    • Affects Version/s: None
    • Component/s: Error Handling
    • None

      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.

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: