netError translates an error from underlying Conn to corresponding net.Error.
(err error)
| 277 | |
| 278 | // netError translates an error from underlying Conn to corresponding net.Error. |
| 279 | func netError(err error) error { |
| 280 | switch { |
| 281 | case errors.Is(err, io.EOF), errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded): |
| 282 | // Return io.EOF and context errors as is. |
| 283 | return err |
| 284 | } |
| 285 | |
| 286 | var ( |
| 287 | ne net.Error |
| 288 | opError *net.OpError |
| 289 | se *os.SyscallError |
| 290 | ) |
| 291 | |
| 292 | if errors.As(err, &opError) { //nolint:nestif |
| 293 | if errors.As(opError, &se) { |
| 294 | if se.Timeout() { |
| 295 | return &TimeoutError{Err: err} |
| 296 | } |
| 297 | if isOpErrorTemporary(se) { |
| 298 | return &TemporaryError{Err: err} |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | if errors.As(err, &ne) { |
| 304 | return err |
| 305 | } |
| 306 | |
| 307 | return &FatalError{Err: err} |
| 308 | } |
searching dependent graphs…