Standard library / crypto/tls
tls.AlertError.Error()
Formats a TLS alert code as an error message. The sample uses a synthetic alert, not a captured handshake failure. Expected stdout: 'tls: handshake failure\n'.
Formal Syntax & Structure
go syntaxgo
func (e AlertError) Error() stringReturn Value
string
Result of the operation; handle any returned error before using other results.
Working Example
Example Snippetgo
package main
import ( "crypto/tls" "fmt")
func main() { fmt.Println(tls.AlertError(40).Error()) }
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}