errutil

package
v1.112.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errutil provides utility functions to handle errors.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinFnError

func JoinFnError(err *error, fn ErrorFunc)

JoinFnError appends the error returned by fn to the error pointed to by err.

Example
package main

import (
	"errors"
	"fmt"

	"github.com/tecnickcom/gogen/pkg/errutil"
)

func main() {
	err := errors.New("original error")

	fn := func() error {
		return errors.New("function error")
	}

	errutil.JoinFnError(&err, fn)

	fmt.Println(err)

}
Output:

original error
function error

func Trace

func Trace(err error) error

Trace annotates the error message with the filename, line number, and function name.

Example
package main

import (
	"errors"
	"fmt"

	"github.com/tecnickcom/gogen/pkg/errutil"
)

func main() {
	err := errors.New("example error")
	testErr := errutil.Trace(err)

	fmt.Println(testErr)
}

Types

type ErrorFunc

type ErrorFunc func() error

ErrorFunc is a function type that returns an error.

Jump to

Keyboard shortcuts

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