This message was deleted.
# getting-started
s
This message was deleted.
👍 1
p
I am using github.com/pkg/errors and always do something like:
Copy code
if err != nil {
	return errors.Wrapf(err, "message with error context goes here")
}
It is not bad and I usually can track down any error. But I must say I don't like it.
s
so you can track it by using that message you provide?
g
You have many options here and if you don't provide addition context when encountering an error I understand how that feels hard. I typically write a func to handle errors generally. Use ctx.Log.Error(err.Error()) with some nice text to help yourself. Golang is the choice here introducing this friction as it forces you to handle your errors. Here is no exception, I really prefer this honestly. If there is an error you want it to fail fast just call os.Exit(1) to stop before.moving further.
p
@some-grass-63999 The message yes, but there is something better. Try this:
Copy code
func main() {

	err := errors.New("something very bad happened")

	err = errors.Wrap(err, "even worse")

	err = errors.Wrap(err, "bad bad")

	fmt.Printf("%+v", err)
}
(note
"%+v"
)
experimenting a little bit more:
Copy code
func main() {
	err := func1()

	fmt.Printf("%+v", err)
}

func func1() error {
	return func2()
}

func func2() error {
	return errors.New("something very bad happened")
}
this one also prints the call stack