errors.go 650 B

123456789101112131415161718192021222324252627282930
  1. package imagedata
  2. import (
  3. "fmt"
  4. "net/http"
  5. "github.com/imgproxy/imgproxy/v3/fetcher"
  6. "github.com/imgproxy/imgproxy/v3/ierrors"
  7. )
  8. type FileSizeError struct{}
  9. func newFileSizeError() error {
  10. return ierrors.Wrap(
  11. FileSizeError{},
  12. 1,
  13. ierrors.WithStatusCode(http.StatusUnprocessableEntity),
  14. ierrors.WithPublicMessage("Invalid source image"),
  15. ierrors.WithShouldReport(false),
  16. )
  17. }
  18. func (e FileSizeError) Error() string { return "Source image file is too big" }
  19. func wrapDownloadError(err error, desc string) error {
  20. return ierrors.Wrap(
  21. fetcher.WrapError(err), 0,
  22. ierrors.WithPrefix(fmt.Sprintf("can't download %s", desc)),
  23. )
  24. }