IsShutdownError checks if the error is related to shutdown (EOF, connection closed, etc.) This is useful for gracefully handling errors during application shutdown.
(err error)
| 50 | // IsShutdownError checks if the error is related to shutdown (EOF, connection closed, etc.) |
| 51 | // This is useful for gracefully handling errors during application shutdown. |
| 52 | func IsShutdownError(err error) bool { |
| 53 | if err == nil { |
| 54 | return false |
| 55 | } |
| 56 | // Check for EOF errors |
| 57 | if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { |
| 58 | return true |
| 59 | } |
| 60 | // Check error message for common shutdown-related patterns |
| 61 | errStr := err.Error() |
| 62 | return strings.Contains(errStr, "EOF") || |
| 63 | strings.Contains(errStr, "connection refused") || |
| 64 | strings.Contains(errStr, "connection reset") || |
| 65 | strings.Contains(errStr, "broken pipe") || |
| 66 | strings.Contains(errStr, "use of closed network connection") |
| 67 | } |
| 68 | |
| 69 | func ReplaceHost(currentURL string, ipAddress string) (string, error) { |
| 70 | // Parse the current URL |
no test coverage detected