From e2c90c96e8ad6c7b7095c32be0e45e1216c77093 Mon Sep 17 00:00:00 2001 From: Matt Dale <9760375+matthewdale@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:54:40 -0700 Subject: [PATCH] GODRIVER-2929 Make driver.ErrDeadlineWouldBeExceeded wrap context.DeadlineExceeded (#1355) --- x/mongo/driver/errors.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/x/mongo/driver/errors.go b/x/mongo/driver/errors.go index a9fcb50125..55f2fb37eb 100644 --- a/x/mongo/driver/errors.go +++ b/x/mongo/driver/errors.go @@ -8,6 +8,7 @@ package driver import ( "bytes" + "context" "errors" "fmt" "strings" @@ -51,9 +52,12 @@ var ( // ErrUnsupportedStorageEngine is returned when a retryable write is attempted against a server // that uses a storage engine that does not support retryable writes ErrUnsupportedStorageEngine = errors.New("this MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string") - // ErrDeadlineWouldBeExceeded is returned when a Timeout set on an operation would be exceeded - // if the operation were sent to the server. - ErrDeadlineWouldBeExceeded = errors.New("operation not sent to server, as Timeout would be exceeded") + // ErrDeadlineWouldBeExceeded is returned when a Timeout set on an operation + // would be exceeded if the operation were sent to the server. It wraps + // context.DeadlineExceeded. + ErrDeadlineWouldBeExceeded = fmt.Errorf( + "operation not sent to server, as Timeout would be exceeded: %w", + context.DeadlineExceeded) // ErrNegativeMaxTime is returned when MaxTime on an operation is a negative value. ErrNegativeMaxTime = errors.New("a negative value was provided for MaxTime on an operation") )