(err error)
| 141 | } |
| 142 | |
| 143 | func ClassifyConnError(err error) (string, string) { |
| 144 | code := utilds.GetErrorCode(err) |
| 145 | subCode := utilds.GetErrorSubCode(err) |
| 146 | if code != "" { |
| 147 | return code, subCode |
| 148 | } |
| 149 | var dnsErr *net.DNSError |
| 150 | if errors.As(err, &dnsErr) { |
| 151 | return ConnErrCode_Dial, ClassifyDialErrorSubCode(err) |
| 152 | } |
| 153 | var opErr *net.OpError |
| 154 | if errors.As(err, &opErr) { |
| 155 | return ConnErrCode_Dial, ClassifyDialErrorSubCode(err) |
| 156 | } |
| 157 | errStr := err.Error() |
| 158 | if strings.Contains(errStr, "unable to authenticate") { |
| 159 | return ConnErrCode_AuthFailed, AuthSubCode_UnableToAuth |
| 160 | } |
| 161 | if strings.Contains(errStr, "handshake failed") { |
| 162 | return ConnErrCode_AuthFailed, AuthSubCode_HandshakeFailed |
| 163 | } |
| 164 | if strings.Contains(errStr, "connection refused") { |
| 165 | return ConnErrCode_Dial, ClassifyDialErrorSubCode(err) |
| 166 | } |
| 167 | if strings.Contains(errStr, "timed out") || strings.Contains(errStr, "timeout") { |
| 168 | return ConnErrCode_Dial, ClassifyDialErrorSubCode(err) |
| 169 | } |
| 170 | return ConnErrCode_Unknown, "" |
| 171 | } |
| 172 | |
| 173 | // ClassifyDialErrorSubCode provides more granular classification of dial errors |
| 174 | // to help identify root causes (DNS, VPN, timeouts, etc.) |
no test coverage detected