Middleware: Context timeout expansion (#2048)
## Description Adds additional definitions for context timeouts for middleware usage <!-- Insert PR description--> ## Does this PR need a docs update or release note? - [x] ⛔ No ## Type of change - [x] 🐛 Bugfix ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> *related #2047<issue> ## Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual
This commit is contained in:
parent
3a37584938
commit
dc17c68074
@ -1,7 +1,9 @@
|
||||
package graph
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
||||
"github.com/pkg/errors"
|
||||
@ -126,6 +128,10 @@ func hasErrorCode(err error, codes ...string) bool {
|
||||
// timeouts as other errors are handled within a middleware in the
|
||||
// client.
|
||||
func isTimeoutErr(err error) bool {
|
||||
if errors.Is(err, context.DeadlineExceeded) || os.IsTimeout(err) {
|
||||
return true
|
||||
}
|
||||
|
||||
switch err := err.(type) {
|
||||
case *url.Error:
|
||||
return err.Timeout()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user