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

Properly wrap and provide Unwrap implementations for error types

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0
    • Component/s: Error Handling
    • Security Level: Public
    • Labels:
      None
    • Case:

      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

            Assignee:
            divjot.arora Divjot Arora
            Reporter:
            divjot.arora Divjot Arora
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: