errors.go 515 B

12345678910111213141516171819202122232425262728
  1. package errors
  2. import (
  3. "fmt"
  4. "go-common/library/ecode"
  5. )
  6. // DependError for show like "model(%s) code(%s) error"
  7. type DependError struct {
  8. errInfo string
  9. Err error
  10. }
  11. // New new a video error.
  12. func New(errInfo string, m error) error {
  13. return &DependError{errInfo, m}
  14. }
  15. // Ecode return ecode.
  16. func (e *DependError) Ecode() error {
  17. return e.Err
  18. }
  19. // Error implement error interface.
  20. func (e *DependError) Error() string {
  21. m := ecode.String(e.Err.Error()).Message()
  22. return fmt.Sprintf(m, e.errInfo)
  23. }