3// From go1.21 and onwards.
13// FormatAlert formats a TLS alert in the form "alert-<num>" or "alert-<num>-<shortcode>".
14func FormatAlert(alert uint8) string {
15 s := fmt.Sprintf("alert-%d", alert)
16 err := tls.AlertError(alert) // Since go1.21.0
17 // crypto/tls returns messages like "tls: short message" or "tls: alert(321)".
18 if str := err.Error(); !strings.Contains(str, "alert(") {
19 s += "-" + strings.ReplaceAll(strings.TrimPrefix(str, "tls: "), " ", "-")