err.go 358 B

1234567891011121314151617181920212223
  1. package liberr
  2. import (
  3. "context"
  4. "github.com/gogf/gf/v2/frame/g"
  5. )
  6. func ErrIsNil(ctx context.Context, err error, msg ...string) {
  7. if !g.IsNil(err) {
  8. if len(msg) > 0 {
  9. g.Log().Error(ctx, err.Error())
  10. panic(msg[0])
  11. } else {
  12. panic(err.Error())
  13. }
  14. }
  15. }
  16. func ValueIsNil(value interface{}, msg string) {
  17. if g.IsNil(value) {
  18. panic(msg)
  19. }
  20. }