[GODRIVER-1581] Properly wrap and provide Unwrap implementations for error types Created: 15/Apr/20  Updated: 28/Oct/23  Resolved: 24/Jun/20

Status: Closed
Project: Go Driver
Component/s: Error Handling
Affects Version/s: None
Fix Version/s: 1.4.0

Type: Improvement Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
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.



 Comments   
Comment by Githook User [ 24/Jun/20 ]

Author:

{'name': 'Divjot Arora', 'email': 'divjot.arora@10gen.com', 'username': 'divjotarora'}

Message: GODRIVER-1581 Transform network errors into context.DeadlineExceeded (#430)

If a context is translated to a network read/write deadline and the
read/write call returns a timeout error, this commit will swallow
that error and replace it with context.DeadlineExceeded so the
resulting error will return true for
errors.Is(err, context.DeadlineExceeded).
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/7d3355f224323a9c0e8769af8114380638a28599

Comment by Divjot Arora (Inactive) [ 22/Jun/20 ]

Moving to "in code review" to address https://github.com/mongodb/mongo-go-driver/pull/430

Comment by Githook User [ 05/May/20 ]

Author:

{'name': 'Divjot Arora', 'email': 'divjot.arora@10gen.com', 'username': 'divjotarora'}

Message: GODRIVER-1581 Implement Unwrap for all wrapping error types (#394)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/c335d0ce4c36997dc5a85083f163ecf4f1af3f48

Comment by Divjot Arora (Inactive) [ 30/Apr/20 ]

https://github.com/mongodb/mongo-go-driver/pull/394

Generated at Thu Feb 08 08:36:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.