errappend

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errappend provides an interface for error types that want to provide a custom error message when appended to a byte slice.

Example
err := errbase.New("error")
b := Append(nil, err)
fmt.Println(string(b))
Output:
error

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(b []byte, err error) []byte

Append appends the error message of the given error to the given byte slice and returns the resulting byte slice. If the given error is nil, the given byte slice is returned unchanged. If the given error implements the Interface interface, its Interface.ErrorAppend method is called to append the error message to the byte slice. Otherwise, the error message is appended to the byte slice using the [error.Error] method.

func String

func String(err Interface) string

String returns the error message of the given error as a string.

Types

type Interface

type Interface interface {
	error
	ErrorAppend(b []byte) []byte
}

Interface is an interface that can be implemented by error types that want to provide a custom error message when appended to a byte slice.

Jump to

Keyboard shortcuts

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