diff --git a/internal/netxlite/errorsx/classify.go b/internal/netxlite/errorsx/classify.go index 7af75da07f..9848d0a10b 100644 --- a/internal/netxlite/errorsx/classify.go +++ b/internal/netxlite/errorsx/classify.go @@ -90,6 +90,9 @@ func classifyWithStringSuffix(err error) string { // that we return here is significantly more specific. return FailureDNSNXDOMAINError } + if strings.HasSuffix(s, "use of closed network connection") { + return FailureConnectionAlreadyClosed + } return "" // not found } diff --git a/internal/netxlite/errorsx/classify_test.go b/internal/netxlite/errorsx/classify_test.go index 3759336965..896652558c 100644 --- a/internal/netxlite/errorsx/classify_test.go +++ b/internal/netxlite/errorsx/classify_test.go @@ -77,6 +77,13 @@ func TestClassifyGenericError(t *testing.T) { } }) + t.Run("for use of closed network connection", func(t *testing.T) { + err := errors.New("read tcp 10.0.2.15:56948->93.184.216.34:443: use of closed network connection") + if ClassifyGenericError(err) != FailureConnectionAlreadyClosed { + t.Fatal("unexpected results") + } + }) + // Now we're back in ClassifyGenericError t.Run("for context.Canceled", func(t *testing.T) { @@ -87,8 +94,8 @@ func TestClassifyGenericError(t *testing.T) { t.Run("for unknown errors", func(t *testing.T) { t.Run("with an IPv4 address", func(t *testing.T) { - input := errors.New("read tcp 10.0.2.15:56948->93.184.216.34:443: use of closed network connection") - expected := "unknown_failure: read tcp [scrubbed]->[scrubbed]: use of closed network connection" + input := errors.New("read tcp 10.0.2.15:56948->93.184.216.34:443: some error") + expected := "unknown_failure: read tcp [scrubbed]->[scrubbed]: some error" out := ClassifyGenericError(input) if out != expected { t.Fatal(cmp.Diff(expected, out)) @@ -96,8 +103,8 @@ func TestClassifyGenericError(t *testing.T) { }) t.Run("with an IPv6 address", func(t *testing.T) { - input := errors.New("read tcp [::1]:56948->[::1]:443: use of closed network connection") - expected := "unknown_failure: read tcp [scrubbed]->[scrubbed]: use of closed network connection" + input := errors.New("read tcp [::1]:56948->[::1]:443: some error") + expected := "unknown_failure: read tcp [scrubbed]->[scrubbed]: some error" out := ClassifyGenericError(input) if out != expected { t.Fatal(cmp.Diff(expected, out)) diff --git a/internal/netxlite/errorsx/errno.go b/internal/netxlite/errorsx/errno.go index aa0bc1ece9..9b21643e0c 100644 --- a/internal/netxlite/errorsx/errno.go +++ b/internal/netxlite/errorsx/errno.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// Generated: 2021-09-08 23:09:33.336763 +0200 CEST m=+0.192836793 +// Generated: 2021-09-27 14:20:26.411929 +0200 CEST m=+0.233208042 package errorsx @@ -58,6 +58,7 @@ const ( FailureSSLUnknownAuthority = "ssl_unknown_authority" FailureSSLInvalidCertificate = "ssl_invalid_certificate" FailureJSONParseError = "json_parse_error" + FailureConnectionAlreadyClosed = "connection_already_closed" ) // failureMap lists all failures so we can match them @@ -101,6 +102,7 @@ var failuresMap = map[string]string{ "ssl_unknown_authority": "ssl_unknown_authority", "ssl_invalid_certificate": "ssl_invalid_certificate", "json_parse_error": "json_parse_error", + "connection_already_closed": "connection_already_closed", } // classifySyscallError converts a syscall error to the diff --git a/internal/netxlite/errorsx/errno_test.go b/internal/netxlite/errorsx/errno_test.go index b5f5709926..8130aec092 100644 --- a/internal/netxlite/errorsx/errno_test.go +++ b/internal/netxlite/errorsx/errno_test.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// Generated: 2021-09-08 23:09:33.382965 +0200 CEST m=+0.239039834 +// Generated: 2021-09-27 14:20:26.459041 +0200 CEST m=+0.280321626 package errorsx diff --git a/internal/netxlite/errorsx/errno_unix.go b/internal/netxlite/errorsx/errno_unix.go index 8a6ad8cbc4..596197c323 100644 --- a/internal/netxlite/errorsx/errno_unix.go +++ b/internal/netxlite/errorsx/errno_unix.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// Generated: 2021-09-08 23:09:33.144513 +0200 CEST m=+0.000582543 +// Generated: 2021-09-27 14:20:26.179327 +0200 CEST m=+0.000601459 package errorsx diff --git a/internal/netxlite/errorsx/errno_windows.go b/internal/netxlite/errorsx/errno_windows.go index 78fde75cee..bb8bcb0b84 100644 --- a/internal/netxlite/errorsx/errno_windows.go +++ b/internal/netxlite/errorsx/errno_windows.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// Generated: 2021-09-08 23:09:33.310337 +0200 CEST m=+0.166410043 +// Generated: 2021-09-27 14:20:26.380511 +0200 CEST m=+0.201789292 package errorsx diff --git a/internal/netxlite/errorsx/internal/generrno/main.go b/internal/netxlite/errorsx/internal/generrno/main.go index dd0ab973b4..dcd72f37d0 100644 --- a/internal/netxlite/errorsx/internal/generrno/main.go +++ b/internal/netxlite/errorsx/internal/generrno/main.go @@ -101,6 +101,7 @@ var Specs = []*ErrorSpec{ NewLibraryError("SSL_unknown_authority"), NewLibraryError("SSL_invalid_certificate"), NewLibraryError("JSON_parse_error"), + NewLibraryError("connection_already_closed"), } func fileCreate(filename string) *os.File {