Skip to content

Commit

Permalink
use proper type of error code for hard failure check (#366)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #366

http.Client returns errors of type *url.Error which is no longer *net.OpErr
add check for this type of errors in isHardFailure() check

Reviewed By: leoleovich

Differential Revision: D58670925

fbshipit-source-id: 7db245b0eadcd18f38eee3b9b931fefbd482670c
  • Loading branch information
vvfedorenko authored and facebook-github-bot committed Jun 17, 2024
1 parent 787b111 commit 8111a2d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions calnex/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package export
import (
"errors"
"net"
"net/url"
"time"

"github.com/facebook/time/calnex/api"
Expand All @@ -31,11 +32,17 @@ var errNoTarget = errors.New("no target succeeds")
// returns true if the error is a hard failure
func isHardFailure(err error) bool {
var opErr *net.OpError
var urlErr *url.Error
if errors.As(err, &opErr) {
if opErr.Timeout() || !opErr.Temporary() {
return true
}
}
if errors.As(err, &urlErr) {
if urlErr.Timeout() || !urlErr.Temporary() {
return true
}
}
return false
}

Expand Down

0 comments on commit 8111a2d

Please sign in to comment.