package common import ( "github.com/sirupsen/logrus" "sync" ) // Error 框架层处理错误 type Error struct { Logger *logrus.Logger error mu sync.RWMutex } func (that *Error) GetError() error { that.mu.RLock() defer that.mu.RUnlock() return that.error } func (that *Error) SetError(err error) { that.mu.Lock() that.error = err that.mu.Unlock() if that.Logger != nil && err != nil { that.Logger.Warn(err) } }