connerr

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package connerr sorts errors from connecting to a broker or a Schema Registry into a few stable classes with fixed texts. A class text never contains an address, host name, port, resolver detail or operating system error string, so it may be returned to a client that supplied the destination. The full error belongs in the server log only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Message

func Message(err error) string

Message returns the text of the class of err, or "" when err is nil.

func WithClass

func WithClass(c Class, err error) error

WithClass marks err as class c for Classify. The result has the text of err and unwraps to it. It returns nil when err is nil.

Types

type Class

type Class string

Class is the kind of a connection failure. Its value is stable and machine-readable; Message is its client-facing text.

const (
	// Refused: the destination refused the connection.
	Refused Class = "refused"
	// Timeout: connecting, or a request on the connection, timed out.
	Timeout Class = "timeout"
	// DNS: a host name did not resolve.
	DNS Class = "dns"
	// TLS: the TLS handshake failed, or one side expected TLS and the
	// other did not.
	TLS Class = "tls"
	// SASL: the broker refused the credentials or the SASL mechanism.
	SASL Class = "sasl"
	// Blocked: the outbound address guard refused the destination.
	Blocked Class = "blocked"
	// Unreachable: any other failure.
	Unreachable Class = "unreachable"
)

The connection error classes.

func Classes

func Classes() []Class

Classes returns every class.

func Classify

func Classify(err error) Class

Classify returns the class of err, or "" when err is nil. An error marked by WithClass has the marked class; an error it does not recognise is Unreachable.

func (Class) Message

func (c Class) Message() string

Message returns the fixed English text of c, or "" when c is not a class.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL