34 lines
389 B
Go
34 lines
389 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func error1() error {
|
|
return errors.New("error1")
|
|
}
|
|
|
|
func error2() (err error) {
|
|
err = error1()
|
|
if err != nil {
|
|
return errors.Wrap(err, "error2")
|
|
}
|
|
return
|
|
}
|
|
|
|
func error3() (err error) {
|
|
return
|
|
}
|
|
|
|
func main() {
|
|
err := error2()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
err = error3()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
}
|