service.go 387 B

12345678910111213141516171819202122232425
  1. package service
  2. import (
  3. "fmt"
  4. "github.com/go-admin-team/go-admin-core/logger"
  5. "gorm.io/gorm"
  6. )
  7. type Service struct {
  8. Orm *gorm.DB
  9. Msg string
  10. MsgID string
  11. Log *logger.Helper
  12. Error error
  13. }
  14. func (db *Service) AddError(err error) error {
  15. if db.Error == nil {
  16. db.Error = err
  17. } else if err != nil {
  18. db.Error = fmt.Errorf("%v; %w", db.Error, err)
  19. }
  20. return db.Error
  21. }