fmsg

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func With(internal string) func(error) error

With implements the Fault Wrapper interface and calls `Wrap` with just the internal error message. See `Wrap` for more details.

func WithDesc

func WithDesc(internal, description string) func(error) error

WithDesc allows an additional description message to be set. These messages are accessible by calling `GetIssue` on an error chain. These descriptions are intended to be exposed to end-users as error/diagnostic messages.

func Wrap

func Wrap(err error, internal, external string) error

Wrap wraps an error with an internal and an external message. The internal message is just the same as any error wrapping library but the external error message is intended for display to the end-user. It's recommended to use full punctuation and grammar and end the message with a period.

Types

type Issue

type Issue = string

Issue describes an error message that is intended for an end-user to read it. It's named "issue" because this word feels like a "non-technical" alternative to the word "error" which is 1. overused and 2. typically used mainly in tech to describe internal tech issues. Using a different word helps differentiate.

func GetIssue

func GetIssue(err error) Issue

GetIssue returns a space-joined string of all end-user issue messages in the error chain. This message can then be displayed/sent to end users.

func GetIssues

func GetIssues(err error) []Issue

GetIssues returns all end-user intended messages in the input error chain.

Jump to

Keyboard shortcuts

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