package main
import (
"errors"
"fmt"
"github.com/gogf/gf/v2/errors/gerror"
)
func main() {
var err error
err = errors.New("sql error")
err = gerror.Wrap(err, "adding failed")
err = gerror.Wrap(err, "api calling failed")
fmt.Printf(" %%s: %s\n", err)
fmt.Printf("%%-s: %-s\n", err)
fmt.Println("%+s: ")
fmt.Printf("%+s\n", err)
}
// Output:
// %s: api calling failed: adding failed: sql error
// %-s: api calling failed
// %+s:
// 1. api calling failed
// 1). main.main
// /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/other/test.go:14
// 2. adding failed
// 1). main.main
// /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/other/test.go:13
// 3. sql error