IsConnError checks if an error is related to client disconnection or context cancellation.
(err error)
| 207 | |
| 208 | // IsConnError checks if an error is related to client disconnection or context cancellation. |
| 209 | func IsConnError(err error) bool { |
| 210 | if err == nil { |
| 211 | return false |
| 212 | } |
| 213 | |
| 214 | if errors.Is(err, io.EOF) { |
| 215 | return true |
| 216 | } |
| 217 | |
| 218 | if errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.EPIPE) || errors.Is(err, net.ErrClosed) { |
| 219 | return true |
| 220 | } |
| 221 | |
| 222 | errStr := err.Error() |
| 223 | return strings.Contains(errStr, "broken pipe") || |
| 224 | strings.Contains(errStr, "connection reset by peer") |
| 225 | } |
| 226 | |
| 227 | func IsUnrecoverableError(err error) bool { |
| 228 | if errors.Is(err, context.Canceled) { |
no test coverage detected