File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ package  exhttp
2+ 
3+ import  (
4+ 	"errors" 
5+ 	"net" 
6+ 	"syscall" 
7+ 
8+ 	"golang.org/x/net/http2" 
9+ )
10+ 
11+ func  IsNetworkError (err  error ) bool  {
12+ 	if  errno  :=  syscall .Errno (0 ); errors .As (err , & errno ) {
13+ 		// common errnos for network related operations 
14+ 		return  errno  ==  syscall .ENETDOWN  || 
15+ 			errno  ==  syscall .ENETUNREACH  || 
16+ 			errno  ==  syscall .ENETRESET  || 
17+ 			errno  ==  syscall .ECONNABORTED  || 
18+ 			errno  ==  syscall .ECONNRESET  || 
19+ 			errno  ==  syscall .ENOBUFS  || 
20+ 			errno  ==  syscall .ETIMEDOUT  || 
21+ 			errno  ==  syscall .ECONNREFUSED  || 
22+ 			errno  ==  syscall .EHOSTDOWN  || 
23+ 			errno  ==  syscall .EHOSTUNREACH 
24+ 	} else  if  netError  :=  net .Error (nil ); errors .As (err , & netError ) {
25+ 		return  true 
26+ 	} else  if  errors .As (err , & http2.StreamError {}) {
27+ 		return  true 
28+ 	}
29+ 
30+ 	return  false 
31+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ require (
1111	github.com/rs/zerolog  v1.34.0 
1212	github.com/stretchr/testify  v1.10.0 
1313	golang.org/x/exp  v0.0.0-20250506013437-ce4c2cf36ca6 
14+ 	golang.org/x/net  v0.40.0 
1415	golang.org/x/sys  v0.33.0 
1516	golang.org/x/text  v0.25.0 
1617	google.golang.org/protobuf  v1.36.6 
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
2727github.com/stretchr/testify  v1.10.0 /go.mod  h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY =
2828golang.org/x/exp  v0.0.0-20250506013437-ce4c2cf36ca6  h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI =
2929golang.org/x/exp  v0.0.0-20250506013437-ce4c2cf36ca6 /go.mod  h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ =
30+ golang.org/x/net  v0.40.0  h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY =
31+ golang.org/x/net  v0.40.0 /go.mod  h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds =
3032golang.org/x/sys  v0.0.0-20220811171246-fbc7d0a398ab /go.mod  h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
3133golang.org/x/sys  v0.6.0 /go.mod  h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
3234golang.org/x/sys  v0.12.0 /go.mod  h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments