github.com/sohaha/zlsgo@v1.7.13-0.20240501141223-10dd1a906f76/zerror/format_test.go (about) 1 package zerror_test 2 3 import ( 4 "testing" 5 6 "github.com/sohaha/zlsgo/zerror" 7 "github.com/sohaha/zlsgo/zlog" 8 ) 9 10 func TestFormat(t *testing.T) { 11 err := newErr() 12 err = wrap500Err(err) 13 err = wrap999Err(err) 14 zlog.Stack(err) 15 } 16 17 func newErr() error { 18 e := func() error { 19 return zerror.New(400, "The is 400") 20 } 21 return e() 22 } 23 24 func wrap500Err(err error) error { 25 return zerror.Wrap(err, 500, "Wrap 500 NoError") 26 } 27 28 func wrap999Err(err error) error { 29 return zerror.Wrap(err, 999, "Unknown NoError") 30 }