You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error_test.go 371 B

1 month ago
12345678910111213141516171819202122232425262728
  1. package gerrors
  2. import (
  3. "errors"
  4. "fmt"
  5. "testing"
  6. "google.golang.org/grpc/status"
  7. )
  8. func TestError(t *testing.T) {
  9. s, ok := status.FromError(errors.New("err"))
  10. fmt.Println(ok)
  11. fmt.Printf("%+v", *s)
  12. fmt.Println(s.Code())
  13. fmt.Println(a())
  14. }
  15. func a() error {
  16. return b()
  17. }
  18. func b() error {
  19. return c()
  20. }
  21. func c() error {
  22. return WrapError(errors.New("kkk"))
  23. }