errors

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRetryableCategory added in v0.2.0

func IsRetryableCategory(cat ErrorCategory) bool

IsRetryableCategory returns whether a given error category is worth retrying. Client errors (4xx) are never retried. DNS and TLS errors are generally not retried since they indicate configuration problems.

Types

type ErrorCategory added in v0.2.0

type ErrorCategory string

ErrorCategory classifies delivery errors for health metrics and retry decisions.

const (
	// CategorySuccess indicates no error occurred.
	CategorySuccess ErrorCategory = "success"

	// CategoryClientError indicates a 4xx HTTP response.
	// These are permanent failures that should never be retried
	// (bad request, unauthorized, forbidden, not found, etc.).
	CategoryClientError ErrorCategory = "client_error"

	// CategoryServerError indicates a 5xx HTTP response.
	// These are temporary server-side failures that should be retried.
	CategoryServerError ErrorCategory = "server_error"

	// CategoryTimeout indicates a request or connection timeout.
	// Retryable - the server may recover.
	CategoryTimeout ErrorCategory = "timeout"

	// CategoryDNSError indicates the domain could not be resolved.
	// Typically persistent - suggests misconfigured webhook URL.
	CategoryDNSError ErrorCategory = "dns_error"

	// CategoryTLSError indicates a TLS/SSL handshake failure.
	// Usually persistent - certificate issues, protocol mismatch, etc.
	CategoryTLSError ErrorCategory = "tls_error"

	// CategoryConnectionRefused indicates the target actively refused the connection.
	// May be temporary (service restarting) or permanent (wrong port).
	CategoryConnectionRefused ErrorCategory = "connection_refused"

	// CategoryNetworkError covers other network-level errors:
	// connection reset, host unreachable, broken pipe, etc.
	// Typically retryable.
	CategoryNetworkError ErrorCategory = "network_error"

	// CategoryUnknown is used when the error cannot be classified.
	CategoryUnknown ErrorCategory = "unknown"
)

func ClassifyError added in v0.2.0

func ClassifyError(err error) ErrorCategory

ClassifyError inspects a Go error from an HTTP request and returns the appropriate error category. It unwraps url.Error, net.OpError, and other standard library error types to determine the root cause.

func ClassifyHTTPStatus added in v0.2.0

func ClassifyHTTPStatus(statusCode int) ErrorCategory

ClassifyHTTPStatus categorizes an HTTP response status code.

Jump to

Keyboard shortcuts

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