Help us shape the future of Go! Take the 2026 Go Developer Survey

errtext

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package errtext prepares error text for persisted error fields, which the Admin API shows to operators unchanged.

Index

Constants

View Source
const MaxBytes = 64 * 1024

MaxBytes bounds persisted error text. A provider may reply with a body of several megabytes, and error fields are rewritten on every attempt.

Variables

This section is empty.

Functions

func Configure

func Configure(rpcURL string, secrets ...string)

Configure registers the chain RPC URL and other configured secret values. Call it once at startup, before any error text is persisted; until then only URL credentials, queries, and fragments are removed.

func Format

func Format(err error) string

Format keeps error context and supported RPC diagnostics, then redacts and bounds it.

func Redact

func Redact(text string) string

Redact returns text safe to persist in an error field: configured secrets become a placeholder, URLs lose credentials, query, and fragment, and the result fits MaxBytes.

func RedactError

func RedactError(err error) error

RedactError preserves error identity while making its message safe for output.

func RedactPtr

func RedactPtr(text *string) *string

RedactPtr applies Redact to an optional error field; nil stays nil.

Types

type Redactor

type Redactor struct {
	// contains filtered or unexported fields
}

Redactor removes configured secrets from diagnostic text.

func New

func New(rpcURL string, secrets ...string) *Redactor

New creates a request-scoped redactor without changing startup configuration.

func (*Redactor) Format

func (r *Redactor) Format(err error) string

Format uses request-scoped secrets for diagnostic error output.

func (*Redactor) Redact

func (r *Redactor) Redact(text string) string

Redact prepares diagnostic text for operator-facing output.

func (*Redactor) RedactError

func (r *Redactor) RedactError(err error) error

RedactError preserves error identity with a request-scoped safe message.

Jump to

Keyboard shortcuts

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