err.go 475 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * @desc:错误处理
  3. * @company:云南奇讯科技有限公司
  4. * @Author: yixiaohu
  5. * @Date: 2022/3/2 14:53
  6. */
  7. package liberr
  8. import (
  9. "context"
  10. "github.com/gogf/gf/v2/frame/g"
  11. )
  12. func ErrIsNil(ctx context.Context, err error, msg ...string) {
  13. if !g.IsNil(err) {
  14. if len(msg) > 0 {
  15. g.Log().Error(ctx, err.Error())
  16. panic(msg[0])
  17. } else {
  18. panic(err.Error())
  19. }
  20. }
  21. }
  22. func ValueIsNil(value interface{}, msg string) {
  23. if g.IsNil(value) {
  24. panic(msg)
  25. }
  26. }