publicerror

package
v0.49.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package publicerror turns an error into text that is safe to show a client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Message

func Message(err error) string

Message returns err's readable chain without the source locations ctxerrors appends. An error in the chain that is Public gives its own text instead. A nil error gives an empty string.

func Text added in v0.31.0

func Text(message string) string

Text is Message for error text that was already rendered, such as a failure detail a record kept. ctxerrors formats as "message: wrapped [file:line in func]", and nested wraps append their own marker, so every marker sits after the readable chain and the first one is where the text stops being safe to publish.

func WithMessage added in v0.46.0

func WithMessage(text string, cause error) error

WithMessage returns an error whose public text is text and that still matches cause under errors.Is and errors.As.

Types

type Public added in v0.46.0

type Public interface {
	error
	PublicMessage() string
}

Public is an error whose own text is written for the person who reads it. Message returns that text instead of the chain around it, so a limit or refusal reads the same wherever it is reported.

Jump to

Keyboard shortcuts

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