errors.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package main
  2. import (
  3. "errors"
  4. "github.com/leonelquinteros/gotext"
  5. )
  6. var ErrPackagesNotFound = errors.New(gotext.Get("could not find all required packages"))
  7. type NoPkgDestsFoundError struct {
  8. dir string
  9. }
  10. func (e *NoPkgDestsFoundError) Error() string {
  11. return gotext.Get("could not find any package archives listed in %s", e.dir)
  12. }
  13. type SetPkgReasonError struct {
  14. exp bool // explicit
  15. }
  16. func (e *SetPkgReasonError) Error() string {
  17. reason := gotext.Get("explicit")
  18. if !e.exp {
  19. reason = gotext.Get("dependency")
  20. }
  21. return gotext.Get("error updating package install reason to %s", reason)
  22. }
  23. type FindPkgDestError struct {
  24. name, pkgDest string
  25. }
  26. func (e *FindPkgDestError) Error() string {
  27. return gotext.Get(
  28. "the PKGDEST for %s is listed by makepkg but does not exist: %s",
  29. e.name, e.pkgDest)
  30. }
  31. type PkgDestNotInListError struct {
  32. name string
  33. }
  34. func (e *PkgDestNotInListError) Error() string {
  35. return gotext.Get("could not find PKGDEST for: %s", e.name)
  36. }
  37. type FailedIgnoredPkgError struct {
  38. pkgErrors map[string]error
  39. }
  40. func (e *FailedIgnoredPkgError) Error() string {
  41. msg := gotext.Get("Failed to install the following packages. Manual intervention is required:")
  42. for pkg, err := range e.pkgErrors {
  43. msg += "\n" + pkg + " - " + err.Error()
  44. }
  45. return msg
  46. }