cause

package
v1.2.58 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithError

func WithError(cause error, err error) error

WithError annotates cause error with a new error. If cause is nil, WithError returns new error. If err is nil, WithError returns nil.

Example
package main

import (
	"errors"
	"fmt"

	"github.com/searKing/golang/go/error/cause"
)

func main() {
	cause_ := errors.New("whoops")
	err := fmt.Errorf("oh noes")
	err = cause.WithError(cause_, err)
	fmt.Println(err)

}
Output:

oh noes: whoops

Types

This section is empty.

Jump to

Keyboard shortcuts

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