IsConnError checks if an error is related to client disconnection or context cancellation.
(err error)
| 234 | |
| 235 | // IsConnError checks if an error is related to client disconnection or context cancellation. |
| 236 | func IsConnError(err error) bool { |
| 237 | if err == nil { |
| 238 | return false |
| 239 | } |
| 240 | |
| 241 | if errors.Is(err, io.EOF) { |
| 242 | return true |
| 243 | } |
| 244 | |
| 245 | if errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.EPIPE) || errors.Is(err, net.ErrClosed) { |
| 246 | return true |
| 247 | } |
| 248 | |
| 249 | errStr := err.Error() |
| 250 | return strings.Contains(errStr, "broken pipe") || |
| 251 | strings.Contains(errStr, "connection reset by peer") |
| 252 | } |
| 253 | |
| 254 | func IsUnrecoverableError(err error) bool { |
| 255 | if errors.Is(err, context.Canceled) { |
no test coverage detected