Skip to content
/ tre Public

Go package for tracing an error in the call stack

License

Notifications You must be signed in to change notification settings

emicklei/tre

Repository files navigation

tre - tracing error in the call stack

Package tre has the TracingError type to collect stack information when an error is caught.

GoDoc Go Report Card codecov

usage

package main

import (
	"errors"
	"fmt"

	"github.com/emicklei/tre"
)

func main() {
	err := doThis("sing")
	fmt.Println(err.Error())
}

func doThis(task string) error {
	err := doMore("prepare")
	return tre.New(err, "failed to do this", "task", task)
}

func doMore(task string) error {
	ctx := map[string]any{"task": task, "guality": 42}
	return tre.New(doThat(task), "cannot do more", ctx)
}

func doThat(task string) error {
	return tre.New(errors.New("bummer"), "doing that failed", "task", task)
}

see examples/main.go

(c) 2016, http://ernestmicklei.com. MIT License

About

Go package for tracing an error in the call stack

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages